I have trouble reading this csv file downloaded from kaggle
. I have tried using the utf-8 encoding and it was still not able to read the csv file
Asked
Active
Viewed 61 times
0

randbwilliam
- 15
- 3
-
check this: https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python – Ade_1 Aug 10 '21 at 03:34
-
Please provide code and error in text form, rather then in image. – imxitiz Aug 11 '21 at 01:37
2 Answers
1
There might be some special characters in the file.
import pandas as pd
df = pd.read_csv(r"file_path", encoding="latin1")

SmriG6
- 58
- 6
-
That worked out perfectly, thank you! How did you know which encoding to use? – randbwilliam Aug 10 '21 at 12:20
0
with open('filename.csv') as file_info:
print(file_info)
The encoding will be at the end.
data=pd.read_csv('filename.csv', encoding="encoding from file_info")
Works every time.

Rajath Rao - Software Engineer
- 1,107
- 1
- 12
- 26