2017-10-16 177 views
0

我有一個數據的csv文件如下:無法讀取csv文件在python

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 
+0

您的文件不是用UTF-8編碼。你需要找出實際的編碼是什麼。或者嘗試猜測(例如cp1252),看看會發生什麼。 ;) –

回答

2

嘗試

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

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