From 836b24b7819617231bee4f8efa024e8d1911794e Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 16 Feb 2021 09:54:00 -0800 Subject: [PATCH] changes csv to final output version Signed-off-by: Dipti --- py-json/LANforge/lfcli_base.py | 16 ++++++++++------ py-json/realm.py | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/py-json/LANforge/lfcli_base.py b/py-json/LANforge/lfcli_base.py index c9af4e92..981e042a 100644 --- a/py-json/LANforge/lfcli_base.py +++ b/py-json/LANforge/lfcli_base.py @@ -637,17 +637,21 @@ class LFCliBase: return df.to_excel(output_f, index=False) if output_f == 'df': return df - supported_formats = ['csv', 'json', 'stata', 'pickle','html'] - #for format in supported_formats: - # if output_file_type.lower() == format: - # return exec('df.to_' + x + '("'+file_name'")') - + if output_f == 'json': + return df.to_json(output_f) + if output_f == 'stata': + return df.to_stata(output_f) + if output_f == 'pickle': + return df.to_pickle(output_f) + if output_f == 'html': + return df.to_html(output_f) + #takes any format of a file and returns a dataframe of it def file_to_df(self,file_name): return pd.read_csv(file_name) #get difference of all common columns in 2 dataframes. store in def compare_two_df(self,dataframe_one=None,dataframe_two=None): - pass + #get the columns to be compared diff --git a/py-json/realm.py b/py-json/realm.py index 550f3038..781ac812 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -1331,7 +1331,10 @@ class L3CXProfile(LFCliBase): #df to final report file output if necessary if output_format.lower() != 'csv': dataframe_output = pd.read_csv(report_file) - self.df_to_file(dataframe=dataframe_output, output_f=output_format) + final_file = self.df_to_file(dataframe=dataframe_output, output_f=output_format) + #save final file output + #print(report_file) + def refresh_cx(self): for cx_name in self.created_cx.keys():