如何避免读取此csv文件的UnicodeDecodeError?

时间:2017-10-16 04:43:00

标签: python pandas csv dataframe

我有一个csv文件,其数据如下:

Text                                                        Value
RT @AmericanHot We're DONE! . htt…                           A
RT @votevets: Hertha Berlin German #Bundesliga world.…  
RT @votevets: Hertha Berlin players  # world.…               B
RT @HerthaBSC_EN: Hertha BSC stands forever…    
RT @johanbakerr: There's no anthem played                    D

当我将csv文件读为

df = pd.read_csv('Book1.csv')

它给我以下错误。我正在使用python 3.6。请帮忙。

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 33: invalid start byte

1 个答案:

答案 0 :(得分:2)

尝试

 df=pd.read_csv('Book1.csv',dtype='unicode')

  df=pd.read_csv('Book1.csv',dtype='unicode',encoding = "ISO-8859-1")