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

0 votes

While I importing the file it shows

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

Code:

import pandas as pd
a = pd.read_csv("filename.csv")
Jul 23 in Python by Hari
283 views

1 answer to this question.

0 votes

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,

import pandas as pd

data=pd.read_csv("C:\\Users\\akashkumar\\Downloads\\Customers.csv",encoding='latin1')

print(data.head())
answered Jul 23 by Kunal

Related Questions In Python

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
143 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 in Python by anonymous
405 views
0 votes
1 answer

Writing unit tests in Python: How do I start?

If you're brand new to using unittests, ...READ MORE

answered Sep 18, 2018 in Python by Priyaj
• 56,900 points
41 views
0 votes
1 answer

Can't Click an Element in Python Selenium After Successfully Finding It

I've encountered this problem of not being ...READ MORE

answered Oct 4, 2018 in Python by Priyaj
• 56,900 points
1,545 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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 275 views
+4 votes
6 answers
0 votes
1 answer