correction of str concatenation, defaulting to csv file creation

This commit is contained in:
Dipti
2021-02-09 17:00:19 -08:00
parent d3ede7481e
commit e0d1a63f94
3 changed files with 15 additions and 11 deletions

View File

@@ -618,7 +618,7 @@ class LFCliBase:
#================ Pandas Dataframe Functions ======================================
#takes any format of a file and returns a dataframe of it
#takes any dataframe and returns the specified outputfile format of it
def df_to_file(dataframe, outputfile_name_path):
df = dataframe
if output_file_type == 'hdf':
@@ -632,10 +632,10 @@ class LFCliBase:
return df.to_excel(output_file_type, index=False)
if output_file_type == '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'")')
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'")')
#takes any format of a file and returns a dataframe of it
def file_to_df(file_type, file_name):

View File

@@ -1235,8 +1235,8 @@ class L3CXProfile(LFCliBase):
raise ValueError("Cannot find columns requested to be searched. Exiting script, please retry.")
if monitor:
if debug:
print("Json response from LANforge... " + response)
#timestamp
print("Json response from LANforge... " + str(response))
t = datetime.datetime.now()
timestamp= t.strftime("%m/%d/%Y %I:%M:%S")
@@ -1268,10 +1268,12 @@ class L3CXProfile(LFCliBase):
csvfile.close()
#here, do column manipulations
dataframe_output = self.file_to_df()
#here, do csv to df
#here, do df to final report file output
if output_format.lower() != 'csv':
dataframe_output = self.file_to_df()
def refresh_cx(self):

View File

@@ -273,7 +273,9 @@ python3 ./test_ipv4_variable_time.py
if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']:
report_f= str(path) + '/data.' + args.output_format
#always save to csv first
report_f= str(path) + '/data.csv'
#report_f= str(path) + '/data.' + args.output_format
print(report_f)
output=args.output_format
else: