aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qolab/file_utils/__init__.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/qolab/file_utils/__init__.py b/qolab/file_utils/__init__.py
index 456fc2f..849718d 100644
--- a/qolab/file_utils/__init__.py
+++ b/qolab/file_utils/__init__.py
@@ -81,8 +81,11 @@ def save_table_with_header(fname, data, header='', comment_symbol='%', skip_head
_open = open # standard file handler
if compressionmethod == 'gzip':
import gzip
- _open = lambda fname, mode: gzip.open( fname, mode, compresslevel = compresslevel)
- with _open(fname, 'ab') as f:
+ _open = lambda fname, mode: gzip.open( fname, mode=mode, compresslevel = compresslevel)
+ if compressionmethod == 'bzip':
+ import bz2
+ _open = lambda fname, mode: bz2.open( fname, mode=mode, compresslevel = compresslevel)
+ with _open(fname, mode='ab') as f:
if not (file_exist_flag and skip_headers_if_file_exist):
for l in header:
f.write(f'{comment_symbol} {l}\n'.encode('utf-8'))