pandas.read_csv FileNotFoundError: File b'\xe2\x80\xaa' despite correct path

前端 未结 13 1216
南笙
南笙 2020-12-15 20:14

I\'m trying to load a .csv file using the pd.read_csv() function when I get an error despite the file path being correct and using raw strings.

相关标签:
13条回答
  • 2020-12-15 21:05

    There is an another problem on how to delete the characters that seem invisible.

    My solution is copying the filepath from the file windows instead of the property windows.

    That is no problem except that you should fulfill the filepath.

    0 讨论(0)
  • 2020-12-15 21:09

    If you are using windows machine. Try checking the file extension. There is a high possibility of file being saved as fileName.csv.txt instead of fileName.csv You can check this by selecting File name extension checkbox under folder options (Please find screenshot)

    below code worked for me:

    import pandas as pd
    df = pd.read_csv(r"C:\Users\vj_sr\Desktop\VJS\PyLearn\DataFiles\weather_data.csv");
    

    If fileName.csv.txt, rename/correct it to fileName.csv

    windows 10 screen shot

    Hope it works, Good Luck

    0 讨论(0)
  • 2020-12-15 21:10

    I was trying to read the csv file from the folder that was in my 'c:\'drive but, it raises the error of escape,type error, unicode......as such but this code works just take an variable then add r to read it.

    rank = pd.read_csv (r'C:\Users\DELL\Desktop\datasets\iris.csv') 
    df=pd.DataFrame(rank)
    
    0 讨论(0)
  • 2020-12-15 21:12
    import pandas as pd
    
    path1 = 'C:\\Users\\Dell\\Desktop\\Data\\Train_SU63ISt.csv'
    path2 = 'C:\\Users\\Dell\\Desktop\\Data\\Test_0qrQsBZ.csv'
    
    df1 = pd.read_csv(path1)
    df2 = pd.read_csv(path2)
    
    print(df1)
    print(df2)
    
    0 讨论(0)
  • 2020-12-15 21:15

    I had the same problem when running the file with the interactive functionality provided by Visual studio. Switched to running on the native command line and it worked for me.

    0 讨论(0)
  • 2020-12-15 21:15
    data = pd.read_csv('C:\\Users\username\Python\mydata.csv')
    

    This worked for me. Note the double "\\" in "C:\\" where the rest of the folders use only a single "\".

    0 讨论(0)
提交回复
热议问题