An error called UnicodeDecodeError occurred while coming to view the csv file in Pandas.

Asked 1 years ago, Updated 1 years ago, 68 views

I'm sure I followed the example on the blog, but I don't know why there's an error with mine. I'm sure there's a 111.csv file, but I get this error.

import pandas as pd
asdf="c:\\Users\\KJY\\Desktop\\111.csv"
pd.read_csv(asdf)

I coded it like this What's the problem?

python pandas unicodedecodeerror

2022-09-21 14:51

1 Answers

This error is most likely that the csv file is stored in utf-8 encoding.

In a Windows environment, the read_csv function attempts to open a file with cp949, the system's default encoding, and UnicodeDecodeError occurs when the file is stored as utf-8. To read the file assuming cp949 encoding, I tried to decode the byte of the file, but the error occurred because the encoding was different.

If the questioner provided a little more error message, he could have answered it more accurately, but the question was simple and could only be estimated.


2022-09-21 14:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.