File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1173,6 +1173,33 @@ def print_data_tabular(
11731173
11741174 display_or_print_df (filtered_column_df , file )
11751175
1176+
1177+ def save_data_to_csv (
1178+ self ,
1179+ file : IO [str ],
1180+ ) -> None :
1181+ """
1182+ Stores the underlying EventBlocks in a csv format with tab separator, to facilitate copy-paste into spreadsheets.
1183+
1184+ Args:
1185+ file: Which IO stream to print to. Do not use stdout, as tab separator is not preserved.
1186+
1187+ Returns:
1188+ None
1189+ """
1190+ combined_df = self .to_dataframe ()
1191+
1192+ # Filter out some columns and rows for better readability when printing
1193+ filtered_column_df = combined_df .drop (columns = EXCLUDED_COLUMNS_WHEN_PRINTING )
1194+ for filter_name in EXCLUDED_EVENTS_WHEN_PRINTING :
1195+ filtered_column_df = filtered_column_df [
1196+ ~ filtered_column_df ["event_name" ].str .contains (filter_name )
1197+ ]
1198+ filtered_column_df .reset_index (drop = True , inplace = True )
1199+
1200+ filtered_column_df .to_csv (file , sep = "\t " )
1201+
1202+
11761203 # TODO: write unit test
11771204 def find_total_for_module (self , module_name : str ) -> float :
11781205 """
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ def main() -> None:
4343 required = False ,
4444 help = "Provide an optional buffer file path." ,
4545 )
46+ parser .add_argument (
47+ "--csv_path" ,
48+ required = False ,
49+ help = "Provide an optional csv file path." ,
50+ )
4651 parser .add_argument ("--compare_results" , action = "store_true" )
4752
4853 args = parser .parse_args ()
@@ -55,6 +60,8 @@ def main() -> None:
5560 target_time_scale = TimeScale (args .target_time_scale ),
5661 )
5762 inspector .print_data_tabular ()
63+ if args .csv_path :
64+ inspector .save_data_to_csv (args .csv_path )
5865 if args .compare_results :
5966 for event_block in inspector .event_blocks :
6067 if event_block .name == "Execute" :
You can’t perform that action at this time.
0 commit comments