简体   繁体   中英

Python will not read the CSV file at all

I have tried this over and over many times and it still will not work. All that I need to do is to read a csv file, but my program will not do it. I have tried the pandas.read_csv() and it just says it does not have that attribute: My error message

I have also tried importing csv and reading it that way but it refuses to admit that there is a file there: My other error message

And here is my code for pandas:

pd.read_csv('data.csv')

And my code for the rest:

with open('data.csv') as csv_file:
    csv_reader = csv.DictReader(csv_file)

    row = next(csv_reader)
    print(row)

And last but not least, here is the proof that the file exists: Proof

Do not create modules using library names. Rename pandas.py. Try again.

df= pd.read_csv('data.csv')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM