Your Python script is named csv.py
. You need to rename it to something else. Never name your script with the same name as a module.
- Change the name of your script
- Delete the csv.pyc also from the location where you created your csv.py file.
Should work after this.
Further, as pointed out in comments, csv
module does not have a read()
method.
Small example from official documentation
>>> import csv
>>> with open('eggs.csv', 'rb') as csvfile:
... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
... for row in spamreader:
... print ', '.join(row)
Spam, Spam, Spam, Spam, Spam, Baked Beans
Spam, Lovely Spam, Wonderful Spam