Characters mess up during encoding of European Characters

Viewed 22

I am currently trying to output a csv file with a few European languages like German and Spanish. When I create the file, I need to specify an encoding in order to not get messed up output. I tried iso-8859 and cp1252, but there has to be at least a few characters that are messed up (meaning that they are not from the language). Code:

output = open('output.csv', 'w', newline="", encoding='iso_8859_1')

The input that I give to the file is from OpenAI's API.

2 Answers

Just use utf-8:

output = open('output.csv', 'w', newline="", encoding='utf-8')

I don´t know if this is valid for german, but its valid for spanish. Try "latin1" in the encoding

Hope it helps

Related