UnicodeDecodeError when reading CSV file in Pandas with Python

后端 未结 21 2276
野趣味
野趣味 2020-11-22 04:27

I\'m running a program which is processing 30,000 similar files. A random number of them are stopping and producing this error...

File "C:\\Importer\\src         


        
21条回答
  •  再見小時候
    2020-11-22 05:10

    Check the encoding before you pass to pandas. It will slow you down, but...

    with open(path, 'r') as f:
        encoding = f.encoding 
    
    df = pd.read_csv(path,sep=sep, encoding=encoding)
    

    In python 3.7

提交回复
热议问题