Feng Chen
Feng Chen

Reputation: 2253

pd.read_csv: utf-8' codec can't decode byte 0x98 in position 61: invalid start byte

I want to download a csv file from: https://www.osha.gov/fatalities/reports/archive.

enter image description here

Please try the FY15 one.

My code is like:

a=pd.read_csv('C://.../fy15_federal-state_summaries.csv',encoding = "utf-8")

But I still have got the error:

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

I have also tried different ways. But all do not work. Could anyone help me here?

Upvotes: 0

Views: 3749

Answers (1)

Adirmola
Adirmola

Reputation: 853

It is encoding issue.

You need to find out the correct encoding of the file.

In this case it is 1250, so:

a=pd.read_csv(r'C:\...\fy15_federal-state_summaries.csv',encoding = "1250")

Upvotes: 3

Related Questions