Work on temporary hosted files
This commit is contained in:
@@ -122,8 +122,8 @@ def create_export_file(
|
||||
subdir_path: str,
|
||||
filename: str,
|
||||
export_type: str = 'CSV', # CSV, Excel
|
||||
) -> bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
) -> bool|str:
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
hosted_tmp_path = settings.PATH_HOSTED_TMP_ROOT
|
||||
@@ -146,14 +146,20 @@ def create_export_file(
|
||||
if export_type == 'CSV':
|
||||
log.info('Saving dataframe to CSV file')
|
||||
full_dest_path = file_dest_w_subdir+'.csv'
|
||||
filename_w_ext = filename+'.csv'
|
||||
tmp_file_path = os.path.join(subdir_path,filename_w_ext)
|
||||
data_dataframe.to_csv(full_dest_path, columns=column_name_li, index=False)
|
||||
elif export_type == 'Excel':
|
||||
log.info('Saving dataframe to Excel file')
|
||||
full_dest_path = file_dest_w_subdir+'.xlsx'
|
||||
filename_w_ext = filename+'.xlsx'
|
||||
tmp_file_path = os.path.join(subdir_path,filename_w_ext)
|
||||
data_dataframe.to_excel(full_dest_path, columns=column_name_li, index=False) # sheet_name='Sheet_name_1'
|
||||
except:
|
||||
log.exception('Something went wrong while trying to save the export file.')
|
||||
return False
|
||||
|
||||
return True
|
||||
log.info(f'Temp File Path: {tmp_file_path}')
|
||||
|
||||
return tmp_file_path # True
|
||||
# ### END ### API Lib General ### create_export() ###
|
||||
|
||||
Reference in New Issue
Block a user