I am learning to write code in Python. I've décided to write a program to increase smbs typing speed. That's why I've found several text documents to select random words from. I have a problem while reading the french file. It replaces 'é' caracters by '+AOK-'. I've searched for solutions for that issue, they said it was encryption problem. I've tried to change file encryption and to read as 'latin-1', but that did not work. I'm writing code in Pydroid, an IDE for Android.
Asked
Active
Viewed 95 times
2 Answers
1
Try reading the file as: df = pd.read_csv(filename,encoding = "ISO-8859-1")
ISO-8859-1 works well with Latin names

Anshu
- 11
- 1
- 1
0
Have you tried using encoding='utf-8'? like this
with open('x.txt', 'r', encoding='utf-8') as f:
print(f.read())

Angelo
- 122
- 1
- 10
-
1Thank you very much for your answer. Yes, I've already tried to write like that, but it changed nothing. It prints '+aok-' for every 'é' in a random word. – AxterD Feb 09 '21 at 10:27
-
1Can you try to use print("é") just to see what the console prints out, in case it's an issue related to the IDE you are using – Angelo Feb 09 '21 at 17:08
-
I can print 'é' and other french caracters, so i don't think that is IDE's problem. – AxterD Feb 09 '21 at 19:12