mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-20 20:14:57 +00:00
commented out broken code, added code so output_format and report_file exten. is passed in, exten is changed to csv to create file, then csv is changed to correct output format
This commit is contained in:
@@ -633,9 +633,9 @@ class LFCliBase:
|
|||||||
if output_file_type == 'df':
|
if output_file_type == 'df':
|
||||||
return df
|
return df
|
||||||
supported_formats = ['csv', 'json', 'stata', 'pickle','html']
|
supported_formats = ['csv', 'json', 'stata', 'pickle','html']
|
||||||
for format in supported_formats:
|
#for format in supported_formats:
|
||||||
if output_file_type.lower() == format:
|
# if output_file_type.lower() == format:
|
||||||
return exec('df.to_' + x + '("'+file_name'")')
|
# return exec('df.to_' + x + '("'+file_name'")')
|
||||||
|
|
||||||
#takes any format of a file and returns a dataframe of it
|
#takes any format of a file and returns a dataframe of it
|
||||||
def file_to_df(file_type, file_name):
|
def file_to_df(file_type, file_name):
|
||||||
|
|||||||
@@ -1186,11 +1186,13 @@ class L3CXProfile(LFCliBase):
|
|||||||
raise ValueError("L3CXProfile::monitor wants a list of column names to monitor")
|
raise ValueError("L3CXProfile::monitor wants a list of column names to monitor")
|
||||||
if output_format is not None:
|
if output_format is not None:
|
||||||
if output_format.lower() != report_file.split('.')[-1]:
|
if output_format.lower() != report_file.split('.')[-1]:
|
||||||
if output_format.lower() != 'csv':
|
raise ValueError('Filename %s has an extension that does not match output format %s .' % (report_file, output_format))
|
||||||
raise ValueError('Filename %s does not match output format %s' % (report_file, output_format))
|
|
||||||
else:
|
else:
|
||||||
output_format = report_file.split('.')[-1]
|
output_format = report_file.split('.')[-1]
|
||||||
|
|
||||||
|
#default save to csv first
|
||||||
|
if report_file.split('.')[-1] != 'csv':
|
||||||
|
report_file = report_file.replace(str(output_format),'csv',1)
|
||||||
|
|
||||||
#retrieve compared report if specified - turn into dataframe === under construction ===
|
#retrieve compared report if specified - turn into dataframe === under construction ===
|
||||||
if compared_report is not None:
|
if compared_report is not None:
|
||||||
@@ -1268,10 +1270,10 @@ class L3CXProfile(LFCliBase):
|
|||||||
csvfile.close()
|
csvfile.close()
|
||||||
|
|
||||||
#here, do column manipulations
|
#here, do column manipulations
|
||||||
|
|
||||||
#here, do df to final report file output
|
#here, do df to final report file output
|
||||||
if output_format.lower() != 'csv':
|
if output_format.lower() != 'csv':
|
||||||
dataframe_output = self.file_to_df()
|
dataframe_output = self.file_to_df(report_file, output_format)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -268,21 +268,17 @@ python3 ./test_ipv4_variable_time.py
|
|||||||
except:
|
except:
|
||||||
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
curr_dir_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
path = os.path.join(curr_dir_path, new_file_path)
|
path = os.path.join(curr_dir_path, new_file_path)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
print('Saving file to ' + path)
|
|
||||||
|
|
||||||
|
|
||||||
if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']:
|
if args.output_format in ['csv','json','html','hdf','stata','pickle','pdf','png','df','parquet','xlsx']:
|
||||||
#always save to csv first
|
report_f= str(path) + '/data.' + args.output_format
|
||||||
report_f= str(path) + '/data.csv'
|
|
||||||
#report_f= str(path) + '/data.' + args.output_format
|
|
||||||
print(report_f)
|
|
||||||
output=args.output_format
|
output=args.output_format
|
||||||
else:
|
else:
|
||||||
print('Defaulting to csv data file output type, naming it data.csv.')
|
print('Defaulting to csv data file output type, naming it data.csv.')
|
||||||
report_f= str(path)+'/data.csv'
|
report_f= str(path)+'/data.csv'
|
||||||
print(report_f)
|
|
||||||
output='csv'
|
output='csv'
|
||||||
|
if self.debug:
|
||||||
|
print("Saving report data in ... " + report_f)
|
||||||
else:
|
else:
|
||||||
report_f=args.report_file
|
report_f=args.report_file
|
||||||
if args.output_format is None:
|
if args.output_format is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user