Closed KittelC closed 3 years ago
Thank you for reporting this issue and I warmly appreciate your solution suggestion. I implemented it accordingly.
I would not suggest to follow that path. A .csv file is a text file and I see no reason to handle it as a binary file. It is the problem of Python 2, which is falling out of support soon, to handle text and binary data in an inconsistant way. I would rather remove the str(...), since the result of join is str in Python 3 and unicode or str in Python 2 anyway.
I would let this die with dropping py2 support following https://python3statement.org/
And some point I will clean up the code with all this stuff that was necessary to be able to support py2 and py3 versions. Since versions >=1.5.13 spotpy is not tested any more for py2, i.e. support was dropped.
Hello!
I recently updated to v. 1.5.1 and ran into the following error message (I am using Python 2.7):
In the script csv.py, the line: self.db.write(str(','.join(self.header) + '\n')) produces TypeError: write() argument 1 must be unicode, not str
The error seems to come from the line above self.db = io.open(self.dbname + '.csv', 'w')
The native open function supports string as input, or the file must be opened in "wb" mode instead of only "w" (see: https://stackoverflow.com/questions/18449233/2-7-csv-module-wants-unicode-but-doesnt-want-unicode )