Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6217953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:30:57+00:00 2026-05-24T07:30:57+00:00

I am writing this small code which is part of my Django application. It

  • 0

I am writing this small code which is part of my Django application. It is supposed to pick up data from a DB table(MySql) and make a csv file. May be its a very simple error I am getting, but I am not able to resolve it.

Name of the file: write_to_csv.py

import csv  
def createCSV():  
    from django.db import connection, transaction  
    cursor = connection.cursor()  
    cursor.execute("select * from avg_max_min;")  
    csv_writer = csv.writer(open("out.csv", "wt"), delimiter=',')  
    csv_writer.writerow([i[0] for i in cursor.description]) # write headers  
    csv_writer.writerows(cursor)  
    del csv_writer # this will close the CSV file  

Error
Exception Value:
‘module’ object has no attribute ‘writer’
Exception Location: C:\Python26\Lib\site-packages\django\bin\report\src\report ..\report\report_view\write_to_csv.py in createCSV, line 6

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:30:58+00:00Added an answer on May 24, 2026 at 7:30 am

    open‘s second argument should be wb not wt. Other than that, it looks like you are doing everything right.

    If it’s still not working, can you update your question with the results of doing dir(csv)? (It’s most likely that you have some other module installed in your Python distribution or in the same directory as write_to_csv.py with the same name.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application which tests email addresses, for one part of this
I'm writing small VB.Net app which should build reports based on data gathered from
I'm writing this question from the standpoint of an ASP.NET application. However I realize
I was writing this small script the other day.It is a small program which
I am writing a small application in Classic ASP. I have a page which
I'm writing a small application which exposes a simple REST-ish HTTP API. I'm stuck
I am writing a small program as part of a University course. In this
I'm writing a small program which will make a GET request to a server
I'm writing a small tool for experimenting with ELF-64 object code which is intended
I'm writing this question with reference to this one which I wrote yesterday. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.