diff --git a/src/dataprovider/conductcalibprovider.py b/src/dataprovider/conductcalibprovider.py index 185a859dd9de3ee7b5f18c9b9ced2a651b0a475c..b6ec1fe9beb20e8e5df724115360b65d7bac39ae 100644 --- a/src/dataprovider/conductcalibprovider.py +++ b/src/dataprovider/conductcalibprovider.py @@ -4,7 +4,6 @@ import datetime import os import re -import utils class ConductCalibProvider: used_channels = ["C1", "C2"] @@ -22,7 +21,12 @@ class ConductCalibProvider: return calib_run - def export_set_as_file(self, filename: str): + def export_set_as_file(self, filename: str) -> None: + # Test if filename already has a extension ('.' followed by 3 letters) ; if not: append '.csv' + if not re.match(".*\.[a-zA-Z]{3}$", filename): + filename += '.csv' + + # Concatenate the data of all runs of the calibration set in a single pd.Dataframe set_df = pd.DataFrame() for run_id in self.calib_runs: calib_run = self.calib_runs[run_id] @@ -31,9 +35,26 @@ class ConductCalibProvider: run_df["run_id"] = run_id set_df = set_df.append(run_df) - set_df.to_csv(path_or_buf=filename, - sep="\t", - index=False) + # Fix column order. Otherwise they can be randomly set. + column_order = ["run_id", + "standard_cond", + "channel", + "step", + "start_datetime", + "end_datetime", + "stable_start_datetime", + "stable_end_datetime", + "frequency", + "excite", + "headgain", + "mean", + "std", + "valid_auto", + "valid_manu"] + + set_df[column_order].to_csv(path_or_buf=filename, + sep="\t", + index=False) class CalibRun: