DictReader, CSV and Python

Viewed 32

Please help! I am trying to work with a CSV file for a Python Beginners Project

import csv

with open('sales.csv', 'r') as csv_file:
    csv_file = csv.reader(csv_file)

    for line in 'sales.csv':
        print(line[month])

This is the code I am using and I receiving the below error message

Traceback (most recent call last): File "C:\Users\shelb\PycharmProjects\pythonProject5\session 2 homework.py", line 16, in csv_file = csv.reader(csv_file) AttributeError: module 'csv' has no attribute 'reader'

Process finished with exit code 1

This code was running fine about an hour ago and I did not perform any changes and now it will not run.

Any help would be greatly appreciated.

PS i have no file named csv.py as that seems to be a common error and i am receiving an error message when i am trying to import dictreader usind from csv import DictReader

Screenshot

AttributeError: module 'csv' has no attribute 'reader'

0 Answers
Related