Skip to content

Commit 8a9a642

Browse files
committed
Allow to save csv without headers
1 parent b25d426 commit 8a9a642

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

speasy/core/codecs/bundled_codecs/hapi_csv/codec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def save_variables(self,
197197
**kwargs
198198
) -> Union[bool, Buffer]:
199199
hapi_csv_file = _speasy_variables_to_hapi_csv(variables)
200-
return save_hapi_csv(hapi_csv_file, file)
200+
return save_hapi_csv(hapi_csv_file, file, **kwargs)
201201

202202
@property
203203
def supported_extensions(self) -> List[str]:

speasy/core/codecs/bundled_codecs/hapi_csv/writer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pandas as pds
77

88

9-
def _to_csv(hapi_csv_file: HapiCsvFile, dest:io.IOBase, with_headers=True) -> bool:
9+
def _to_csv(hapi_csv_file: HapiCsvFile, dest:io.IOBase, with_headers: bool = True) -> bool:
1010
np_startDate = hapi_csv_file.time_axis[0]
1111
np_stopDate = hapi_csv_file.time_axis[-1]
1212
startDate = np_startDate.astype("datetime64[us]").astype("O")
@@ -39,14 +39,14 @@ def _to_csv(hapi_csv_file: HapiCsvFile, dest:io.IOBase, with_headers=True) -> bo
3939
return True
4040

4141

42-
def save_hapi_csv(hapi_csv_file: HapiCsvFile, file: Optional[Union[str, io.IOBase]] = None) -> Union[bool, Buffer]:
42+
def save_hapi_csv(hapi_csv_file: HapiCsvFile, file: Optional[Union[str, io.IOBase]] = None, with_headers: bool = True) -> Union[bool, Buffer]:
4343
if type(file) is str:
4444
with open(file, 'wb') as f:
45-
return _to_csv(hapi_csv_file, f)
45+
return _to_csv(hapi_csv_file, f, with_headers=with_headers)
4646
elif hasattr(file, 'write'):
47-
return _to_csv(hapi_csv_file, file)
47+
return _to_csv(hapi_csv_file, file, with_headers=with_headers)
4848
elif file is None:
4949
buff = io.BytesIO()
50-
_to_csv(hapi_csv_file, buff)
50+
_to_csv(hapi_csv_file, buff, with_headers=with_headers)
5151
return buff.getvalue()
5252
raise ValueError("Invalid file type")

0 commit comments

Comments
 (0)