-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
csv writer does not work in Python 2 #217
Comments
Thank you for reporting this issue and I warmly appreciate your solution suggestion. I implemented it accordingly. |
* master: (29 commits) Updated the statistics output Updated fscabc Updated fscabc Fix for thouska#217 Update version number Update new style of Rosenbrock example on docs thouska#213 Add missing keyword, fix for thouska#213 Update version number Add basic test for parallel computing Remove altobjfunc from dream example Enlarge runs for dream in unittest Update Test script for rosenbrock setup thouska#213 Update new style of rosenbrock_setup Fix for thouska#213 Making status print more informativ Remov Gelman Rubin plot from test suite for Python < 3.6 Remove Hymod support for Python <3.6 Remove copy functions for py2 support Add classmethod statement WIP fix Python 2 errors ... # Conflicts: # spotpy/__init__.py # spotpy/algorithms/_algorithm.py
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. |
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 )
The text was updated successfully, but these errors were encountered: