I want to open and read an excel file with pd.read_excel using utf-8 (so other languages could be read) as in read_csv the encodings can be set to utf-8, is it possible somehow?
-
1Does this answer your question? Pandas read _excel: 'utf-8' codec can't decode byte 0xa8 in position 14: invalid start byteSanjay SS– Sanjay SS2021-10-14 18:08:24 +00:00Commented Oct 14, 2021 at 18:08
-
If you're opening an actual Excel file (.xlsx) I'm not sure you can change the decoding. But the characters should come back correct regardless. What's the error you're getting?Mark Ransom– Mark Ransom2024-03-06 16:52:11 +00:00Commented Mar 6, 2024 at 16:52
Add a comment
|
1 Answer
You may pass an open file:
with open("file_path", encoding="utf-8") as f:
pd.read_excel(f)
I didn't find a reference in the docs but a quick look in pandas code suggests "utf-8" might be the default already.
1 Comment
Bar Kadosh
Thank you! it seems I have a problem when trying to use the values (from the excel file) for text in kivy labels for example, so the codec does work, how can I fix it?