diff --git a/tibanna/top.py b/tibanna/top.py index 3d217646..e018a8ed 100644 --- a/tibanna/top.py +++ b/tibanna/top.py @@ -231,7 +231,9 @@ def write_to_csv(self, csv_file, metric='cpu', delimiter=',', colname_for_timest last_minute = 5 with open(csv_file, 'w') as fo: # header - fo.write(delimiter.join([colname_for_timestamps] + [Top.wrap_in_double_quotes(cmd) for cmd in self.commands])) + # we have to escape any double quotes that are present in the cmd, before wrapping it in double quotes. Otherwise we + # will get incorrect column counts when creating the metrics report. + fo.write(delimiter.join([colname_for_timestamps] + [Top.wrap_in_double_quotes(cmd.replace('"', '""')) for cmd in self.commands])) fo.write('\n') # contents # skip timepoints earlier than timestamp_start