From b53e004b5bb36f1a309cd528690eb1438d58042f Mon Sep 17 00:00:00 2001 From: Andy Sigler Date: Tue, 1 Aug 2023 15:30:00 -0400 Subject: [PATCH] adds first line to CSV reports helping operators copy data --- .../hardware_testing/data/csv_report.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hardware-testing/hardware_testing/data/csv_report.py b/hardware-testing/hardware_testing/data/csv_report.py index ae05daf32c8..8ae16900f00 100644 --- a/hardware-testing/hardware_testing/data/csv_report.py +++ b/hardware-testing/hardware_testing/data/csv_report.py @@ -92,6 +92,11 @@ def stored(self) -> bool: """Line stored.""" return self._stored + @property + def num_data_points(self) -> int: + """Get the number of data points saved in this line.""" + return len(self._data_types) + def cache_start_time(self, start_time: float) -> None: """Line cache start time.""" self._start_time = start_time @@ -349,7 +354,17 @@ def _refresh_results_overview_values(self) -> None: def __str__(self) -> str: """CSV Report string.""" - return "\n".join([str(s) for s in self._sections]) + max_cols = max( + [ + line.num_data_points + for section in self._sections + for line in section.lines + ] + ) + max_cols += 2 # all lines are prepended with the timestamp and tag + # the first line in the CSV should be populated with "copy" + first_line = ",".join(["copy"] * max_cols) + return f"{first_line}\n" + "\n".join([str(s) for s in self._sections]) @property def completed(self) -> bool: