468,285 Members | 1,534 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,285 developers. It's quick & easy.

Importing a csv file

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>
reader = csv.reader(open("some.csv", "rb"))
AttributeError: 'module' object has no attribute 'reader'

im a total fresher to this python...SO can any one help me out in
this...

Thanks in advance
Sagar Meesala

Apr 30 '07 #1
3 3867
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>
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.

TJG
Apr 30 '07 #2
On Apr 30, 7:21 pm, Tim Golden <m...@timgolden.me.ukwrote:
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.


Apr 30 '07 #3
John Machin wrote:
On Apr 30, 7:21 pm, Tim Golden <m...@timgolden.me.ukwrote:
>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?
It's my natural British diffidence :) We almost never make
unqualified statements.

TJG
Apr 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Jeff Wagner | last post: by
12 posts views Thread by qwweeeit | last post: by
1 post views Thread by Thomas R. Hummel | last post: by
11 posts views Thread by Grim Reaper | last post: by
5 posts views Thread by dixie | last post: by
reply views Thread by Alun Jones | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.