@DeaD_EyE:
You think there is more to it than the fact that the file is written with mixed encodings making it ultra hard to process via python?
I spent one hour after my last post trying to force encodings and decodings, both in python and in the original program, with no success (the program that writes the file has an option to decide the encoding in which it opens the file to write in... which doesn't work and does nothing).
---------------------------------------------------------------------------------
You think there is more to it than the fact that the file is written with mixed encodings making it ultra hard to process via python?
I spent one hour after my last post trying to force encodings and decodings, both in python and in the original program, with no success (the program that writes the file has an option to decide the encoding in which it opens the file to write in... which doesn't work and does nothing).
Quote:You can ship around this problem, if you open the file with the right encoding.This didn't work for me, because the first byte is not compatible with that encoding so it raised an error. All the encoding/decoding was failing on the first byte of the file.
Python Code: (Double-click to select all)
1
with open(filename, encoding='utf-8-sig') as csvfile:
---------------------------------------------------------------------------------
Quote:Well, just strip() these ... things:How would I know these things will be the same for the other files that my script will generate(to be more precise: it's not)? If I have to manually adapt the stripping to each file, I'll just manually copy/paste the date into another file that I save in the right encoding. And if I know these will allways be the first two characters, I think my solution of working in the first line with
>>> "��1.12005000,1.11800000,14574".strip("�") '1.12005000,1.11800000,14574'
a = file.readline() a = a[2:]is more general. Even then, it seems it will allways be the first two characters but I can't be sure of that.