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

前端 未结 13 1217
南笙
南笙 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:17

    Try this and see if it works. This is independent of the path you provide.

    pd.read_csv(r'C:\Users\aiLab\Desktop\example.csv')
    

    Here r is a special character and means raw string. So prefix it to your string literal.

    https://www.journaldev.com/23598/python-raw-string:

    Python raw string is created by prefixing a string literal with ‘r’ or ‘R’. Python raw string treats backslash () as a literal character. This is useful when we want to have a string that contains backslash and don’t want it to be treated as an escape character.

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