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

+1 vote

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
19,156 views

1 answer to this question.

+4 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
Thank you. Worked well for me ....
Glad to hear it :)

Please upvote.

thanks. it worked. 

encoding='latin1' part solved my problem.
thanks worked well
Why does it work ?
Hey guys, how's the corona Quarantine going on? You guys working from home too?
Hey, @Book

It will help if you could just elaborate on your doubt.

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
115 views
0 votes
2 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Python generates the error message you present ...READ MORE

answered Mar 14 in Python by Facts
• 140 points
50,024 views
0 votes
2 answers

Error: Speech to Text Codec cannot decode the bytes in position

import speech_recognition as sr r = sr.Recognizer() audio ='C\Users\Desktop\audiofile1.wav' with ...READ MORE

answered Nov 27, 2018 in Python by Nabarupa Das
421 views
0 votes
2 answers

Python Error "UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)"

import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with ...READ MORE

answered Jun 28, 2019 in Python by anonymous
2,487 views
0 votes
1 answer
+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 773 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer
+1 vote
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
18,818 views