Python Forum
AttributeError: module 'csv' has no attribute 'reader'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: module 'csv' has no attribute 'reader'
#1
Hi All,

I am using below code to read the data from csv file , getting error.

AttributeError: module 'csv' has no attribute 'reader'[/b]

Code:

import csv
path = '/home/user1/python-docs-samples/pubsub/cloud-client/'
file= open( path +"csv.txt", "r")
read_data = csv.reader(file)
for line in read_data:
    t=line[1],line[2]
    print(t)
Please help me to overcome this issue.

Regards,
SP
Reply
#2
Always post full traceback, not just the last line.
Without it I would guess your file name is csv.py effectively overshadowing the built-in module... Or you have other file named csv.py in the same folder as your script.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks a lot Buran .

Your guess is correct, yes I removed the csv.py in the same folder .

Now able to execute the code successfully.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 719 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,530 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 704 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 3,665 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,211 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Pandas AttributeError: 'DataFrame' object has no attribute 'concat' Sameer33 5 5,298 Feb-17-2023, 06:01 PM
Last Post: Sameer33
  xml simple reader kucingkembar 2 1,022 Aug-19-2022, 08:51 PM
Last Post: kucingkembar
  AttributeError: 'numpy.ndarray' object has no attribute 'load' hobbyist 8 6,967 Jul-06-2022, 10:55 AM
Last Post: deanhystad
  AttributeError: 'numpy.int32' object has no attribute 'split' rf_kartal 6 4,192 Jun-24-2022, 08:37 AM
Last Post: Anushka00
  AttributeError: 'list' object has no attribute 'upper' Anldra12 4 4,721 Apr-27-2022, 09:27 AM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020