diff --git a/Scripts/datahandling/resultdata.py b/Scripts/datahandling/resultdata.py index 37e4d786..3f9dbdcc 100644 --- a/Scripts/datahandling/resultdata.py +++ b/Scripts/datahandling/resultdata.py @@ -27,9 +27,13 @@ def flush(self): f.write(row) self._list_buffer = {} for filename in self._df_buffer: - self._df_buffer[filename].to_csv( + df = self._df_buffer[filename] + df.index = df.index.astype(str, copy=False) + # Pad index according to its longest item + df.index = df.index.str.pad(len(max(df.index, key=len))) + df.to_csv( os.path.join(self.path, filename), - sep='\t', float_format="%1.5f") + sep='\t', na_rep=12*' ', float_format="%12.7g") self._df_buffer = {} for filename in self._xlsx_buffer: self._xlsx_buffer[filename].save( @@ -48,6 +52,7 @@ def print_data(self, data, filename, colname): colname : str Desired name of this column """ + colname = colname.rjust(12) if filename not in self._df_buffer: self._df_buffer[filename] = pandas.DataFrame(data, columns=[colname]) else: @@ -74,7 +79,7 @@ def print_matrix(self, data, filename, sheetname): # If no Workbook module available (= _use_txt), save data to csv data.to_csv( os.path.join(self.path, "{}_{}.txt".format(filename, sheetname)), - sep='\t', float_format="%8.1f") + sep='\t', float_format="%12.7g") else: # Get/create new worksheet if filename in self._xlsx_buffer: