From 42007e4e657dda00fc8288aac4ac75ac9ecc5aff Mon Sep 17 00:00:00 2001 From: thouska Date: Mon, 27 May 2019 12:26:32 +0200 Subject: [PATCH] Fix for #217 --- spotpy/database/csv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spotpy/database/csv.py b/spotpy/database/csv.py index 1c051345..9fc7c596 100644 --- a/spotpy/database/csv.py +++ b/spotpy/database/csv.py @@ -23,13 +23,19 @@ def __init__(self, *args, **kwargs): if kwargs.get('dbappend', False) is False: print("* Database file '{}.csv' created.".format(self.dbname)) # Create a open file, which needs to be closed after the sampling - self.db = io.open(self.dbname + '.csv', 'w') + mode = 'w' + if sys.version_info.major < 3: + mode += 'b' + self.db = io.open(self.dbname + '.csv', mode) # write header line self.db.write(unicode(','.join(self.header) + '\n')) else: print("* Appending to database file '{}.csv'.".format(self.dbname)) # Continues writing file - self.db = io.open(self.dbname + '.csv', 'a') + mode = 'a' + if sys.version_info.major < 3: + mode += 'b' + self.db = io.open(self.dbname + '.csv', mode) def save(self, objectivefunction, parameterlist, simulations=None, chains=1): coll = (self.dim_dict['like'](objectivefunction) +