Python: UnicodeDecodeError: "utf-8" codec can"t decode byte 0xa0 in position 10: invalid start byte

+2 votes

Unable to import this file it shows an error. My code was:

import pandas as pd
a = pd.read_csv("filename.csv")
Jul 11, 2019 in Python by Yadu
66,554 views

1 answer to this question.

+5 votes
Best answer

You have to use the encoding as latin1 to read this file as there are some special character in this file, use the below code snippet to read the file. Try this:

import pandas as pd
data=pd.read_csv("C:\\Users\\akashkumar\\Downloads\\Customers.csv",encoding='latin1')
print(data.head())
answered Jul 11, 2019 by Ritu

selected Dec 11, 2019 by Kalgi
worked for me also thanks
OMG! Thank you so much. I was stuck on this for a while!! :D
Thank you!!! that additional encoding='latin1' entirely fixes this issue

Thanks a lot. I was really stuck with this problem. 

Alternatively we can use "encoding='unicode_escape'" with the same effect.

import pandas as pd
data=pd.read_csv("C:\\Users\\akashkumar\\Downloads\\Customers.csv",encoding=''unicode_escape')
print(data.head())

worked for me as well. thanks very much indeed

Related Questions In Python

0 votes
0 answers

utf-8' codec can't decode byte 0xa0 in position 10: invalid start byte

my code import wordcloud import numpy as np from matplotlib ...READ MORE

Mar 29 in Python by anonymous
• 120 points
1,703 views
0 votes
2 answers
0 votes
1 answer

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

Hi, @hala, Regarding your query, you can go ...READ MORE

answered Jun 29 in Python by Niroj
• 80,940 points
2,913 views
0 votes
2 answers

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

Hey,  @Himanshu. It's still most likely gzipped data. ...READ MORE

answered Jul 27 in Python by Gitika
• 54,140 points
1,631 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,591 views
0 votes
0 answers
0 votes
1 answer

Error is "invalid literal for int() with base 10: ' ' "

This error is caused because we try ...READ MORE

answered Oct 15 in Python by Gitika
• 54,140 points
415 views
0 votes
1 answer
+2 votes
1 answer

UnicodeDecodeError: "utf-8" codec can't decode byte in position : invalid start byte

You have to use the encoding as latin1 ...READ MORE

answered Jul 23, 2019 in Python by Kunal
71,137 views