Alex
Alex

Reputation: 81

How to avoid UnicodeDecodeError reading this csv file?

I have a csv file with data as below:

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

when I read the csv file as

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

It gives me below error. I am using python 3.6. Please help.

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

Upvotes: 0

Views: 222

Answers (1)

Pyd
Pyd

Reputation: 6159

try

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

or

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

Upvotes: 1

Related Questions