Reading a csv with pandas, I get the error: 'IOError: File /test.csv does not exist.' Here is how I am reading:
var1 = pd.read_csv("test.csv")
I verified that I am in the correct working directory with:
print(os.getcwd())
Which prints C:\\Users\\name\\folderName, and the test.csv file is in folderName. I also check if the file exists using os.path.isfile('test.csv')
and that returns false. What am I doing incorrectly? I have tried using the full path as well, it did not work.
Edit: I tried opening a .txt file with the same format and everything was fine, so the problem seems to be with the fact that I'm opening a .csv.
The correct path would be
os.path.join(os.getcwd(), test.csv)
os.getcwd()
gives you the path C:\\Users\\name\\folderName and then we join the filename to make the complete path.
问题是文件名“ test.csv”并键入csv而不是csv类型的“ test”。
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.