CNR-Engineering / PyTelTools

Python Telemac Tools for post-processing tasks (includes a workflow)
https://github.com/CNR-Engineering/PyTelTools/wiki
GNU General Public License v3.0
32 stars 15 forks source link

unable to decode units using utf-8 #1

Closed jamaa closed 6 years ago

jamaa commented 7 years ago

First of all, thanks for making this great project available. I had some difficulties installing it under Windows, but now it's working. At first however, I was unable to load any Serafin files and the program would crash with a python error message regarding var_unit.decode('utf-8') I found out that the problem was caused by the variable TEMPERATURE, whose unit is °C. On a whim, I replaced all occurrences in the code of unit.decode('utf-8') with unit.decode('iso-8859-1'), and I can now load Serafin result files just fine. Is this perhaps a Windows-specific problem?

lucduron commented 7 years ago

Thank you @jamaa for having tried and for providing a solution which fixed your problem. Indeed I try not to have special characters in title, variable name and unit, but if they are present the script can crash on a UnicodeDecodeError. I will try on Windows and Linux and will correct it soon. By the way, I have also to improve the Serafin parser to handle litte endian and enable some backward compatibily (with old Serafin conventions) and failsoft to read "strange" Serafin files.

lucduron commented 6 years ago

I improved the Serafin parser to read big/little endian (automatically determined) and read strings in iso-8859-1 encoding. See commit 65e3cb8.