Use the same encoding everywhere
I see that encoding="ISO-xxxx" and encoding="UTF8" are present multiple times in the source code; it is preferable to use the encoding of the system or to use utf-8 everywhere, and it's probably a bad idea to use an encoding for reading csv and another one to write them :-)