Reputation: 139
import csv
import os
import pandas as pd
os.chdir(r'C:\Users\khalha\Desktop\AllSalesForecasting')
dataframe12 = pd.read_csv('54.csv')
june18 = pd.read_csv('54.csv', index_col="Customer")
print(june18)
Even if I dont have the last 2 lines, I am recieveing an error:
FileNotFoundError: File b'54.csv' does not exist
I have no idea why this is happening for I have done many problems using this format, but now it does not seem to work.
Upvotes: 5
Views: 14905
Reputation: 21
unicode error can be solved by using double slash instead of single slash .This worked for me.
Upvotes: 2
Reputation: 1
I had the same problem of getting error message File
b'G:\Tensorflow_tutorial_karim\test.csv' not found.
After searching many links could not get any satisfying reply and neither could pd.read_csv(filename) worked.
I tried with spider I-python console after pasting the test.csv file in C:\workingDirectory. It gave the error message
"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escapeto the effect'cannot decode escape characters".
Taking the clue, I replaced back slash('\') with forward slash ('/')in path and it worked fine.
With this, Jupyter note book also reads the files without any problem.Hope it will work for others also.
Upvotes: 0
Reputation: 139
My error simply existed because I named my file 52.csv, 53.csv, 54.csv, etc. I dropped the .csv when I named them, and it worked fine. (I thought because we are reading 54.csv for example, you have to label the file name as so, when in reality you read it as 54.csv, simply because it is a csv file)
Upvotes: 0