I am dealing with some problems in several encoding files. We receive files from another company and must read them (files are in csv format)
It is strange that the files appear to be encoded in UTF-16. I can do this, but I have to open them using the codecs module and specify the encoding in this way.
ENCODING = 'utf-16' with codecs.open(test_file, encoding=ENCODING) as csv_file:
But, just as I can get the dialect in a more aggressive way, I think it will be great to be able to automatically open files with its proper encoding, at least all text files. There are other programs, such as vim, that achieve this.
Does anyone know a way to do this in python 2.6?
PD: I hope this will be resolved in Python 3, since all lines are Unicode ...
python
Khelben
source share