简体   繁体   中英

import csv into pandas dataframe

I am facing difficulty importing a csv file to python from my desktop. It seems that the file or the location is not being recognized while reading. Have tried several different methods to import, but every time it gives the same error:

IOError: [Errno 2] No such file or directory: '/Users/uditasingh/Desktop/Analysis/monthly_visits.csv'

for the code:

import csv
cr = csv.reader(open("/Users/uditasingh/Desktop/Analysis/monthly_visits.csv","rb"))

I have obtained the path of the csv file from the file 'properties'. Don't understand what seems to be going wrong.

Please help!

Thanks

My bet is that it searches for the Users directory in the code's working dir and obviously can't find it. Try to use the full path, ie 'C:/Users/......`.

try to write

cr = csv.reader(open("\\Users\\uditasingh\\Desktop\\Analysis....))

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