Skip to content

Commit 8fddce5

Browse files
alixdammangdementen
authored andcommitted
fix #313 : Session.save(file.xlsx) creates a new Excel file if it does not exist.
1 parent 62718ea commit 8fddce5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

larray/io/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def dump_arrays(self, key_values, *args, **kwargs):
117117
for key, value in key_values:
118118
if isinstance(value, ABCLArray) and value.ndim == 0:
119119
if display:
120-
print('Cannot dump {}. Dumping 0D arrays is not supported currently.'.format(key))
120+
print('Cannot dump {}. Dumping 0D arrays is currently not supported.'.format(key))
121121
continue
122122
if display:
123123
print("dumping", key, "...", end=' ')
@@ -187,7 +187,8 @@ def _open_for_read(self):
187187
self.handle = open_excel(self.fname)
188188

189189
def _open_for_write(self):
190-
self.handle = open_excel(self.fname)
190+
overwrite_file = not os.path.isfile(self.fname)
191+
self.handle = open_excel(self.fname, overwrite_file=overwrite_file)
191192

192193
def list(self):
193194
return self.handle.sheet_names()

0 commit comments

Comments
 (0)