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

+1 vote

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, 2019 in Python by Hari
36,966 views

1 answer to this question.

+3 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,

import pandas as pd

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

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

selected Dec 24, 2019 by Kalgi
Thanks Kunal you are awesome
Please upvote the answer if its useful :)
Thank you so much, it is helpful answer, I also have same problem but solved
you are great dude!
Hey! Please do register at Edureka Community and upvote the answer if it has helped you.

Thanks
Thank you Sir. Very helpful
thank you saved my life, I was dying to know this solution hahahha
Thanks. it is working.

could you explain? What is the reason for this problem and what that "encoding ='latin1' " mean?
Kunal you're awesome! That was driving me mad

Related Questions In Python

0 votes
1 answer

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

Hi@akhtar, This type of error will occur, if ...READ MORE

answered Apr 9 in Python by MD
• 32,730 points
1,209 views
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
• 33,400 points
202 views
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
725 views
+1 vote
1 answer

'utf-8' codec can't decode byte 0xa9 in position 12527: invalid start byte

Hello, You can always safely read in binary ...READ MORE

answered Jun 29 in Python by Niroj
• 33,400 points
513 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,060 views
0 votes
0 answers
+4 votes
6 answers
+1 vote
1 answer
0 votes
1 answer