Re: Importing a csv file



On Apr 30, 7:21 pm, Tim Golden <m...@xxxxxxxxxxxxxxx> wrote:
sagar wrote:
Hi all ,
I want to read data in a csv file using the python scripts.
when i gave the following code :
import csv
reader = csv.reader(open("some.csv", "rb"))
for row in reader:
print row

it is showing :

Traceback (most recent call last):
File "csv.py", line 1, in <module>
import csv
File "C:\Documents and Settings\meesa02\csv.py", line 2, in <module>

Only *almost* certainly, Tim? *Maybe*? You don't believe what the
above traceback lines are telling you?

reader = csv.reader(open("some.csv", "rb"))
AttributeError: 'module' object has no attribute 'reader'

You almost certainly have a file called "csv.py" in
the current directory. (Maybe even the one that's
running this script?). Rename it to "mycsv.py" or
whatever and try again.




.



Relevant Pages

  • CSV Reader
    ... I want to read in a CSV file, but then write out a new CSV file from a ... I'm using the CSV reader and have the the line where i want to start ... read data file ...
    (comp.lang.python)
  • Re: CSV Reader
    ... I want to read in a CSV file, but then write out a new CSV file from a ... I'm using the CSV reader and have the the line where i want to start ... read data file ...
    (comp.lang.python)
  • Re: Importing a csv file
    ... I want to read data in a csv file using the python scripts. ... 'module' object has no attribute 'reader' ...
    (comp.lang.python)
  • Importing a csv file
    ... I want to read data in a csv file using the python scripts. ... 'module' object has no attribute 'reader' ...
    (comp.lang.python)
  • Re: Importing a csv file
    ... I want to read data in a csv file using the python scripts. ... Traceback: ...
    (comp.lang.python)