0

I tried importing a csv file using

import pandas as pd
df=pd.read_csv("samle.csv")

But there is an error while importing the file :

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

As i looked in the csv file, it had some characters like this: � How do i rectify this error?

2
  • this may seem stupid for a comment... but could you just remove the special character? or are there multiple characters like this? Commented Mar 20, 2017 at 18:28
  • Too many of them...About 5k Commented Mar 21, 2017 at 1:05

1 Answer 1

1

Did you try:

df = pd.read_csv("samle.csv", encoding='ISO-8859-1')
Sign up to request clarification or add additional context in comments.

2 Comments

@user517696, try ISO-8859-1 instead of utf-8 as that character is often associated with ISO.
@zipa Can you update your answer based on my comment? Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.