Skip to content

Commit

Permalink
Fix for #217
Browse files Browse the repository at this point in the history
  • Loading branch information
thouska committed May 27, 2019
1 parent 1346975 commit 42007e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spotpy/database/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down

0 comments on commit 42007e4

Please sign in to comment.