Improving the CRUD v2 file export
This commit is contained in:
@@ -388,13 +388,27 @@ def create_export_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)
|
||||
data_dataframe.to_csv(
|
||||
full_dest_path,
|
||||
# na_rep='NULL',
|
||||
columns=column_name_li,
|
||||
index=False,
|
||||
# errors='ignore',
|
||||
)
|
||||
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'
|
||||
# This should ignore unknown columns
|
||||
data_dataframe.to_excel(
|
||||
full_dest_path,
|
||||
# na_rep='NULL',
|
||||
columns=column_name_li,
|
||||
index=False,
|
||||
# engine='openpyxl',
|
||||
# errors='ignore',
|
||||
)
|
||||
except:
|
||||
log.exception('Something went wrong while trying to save the export file.')
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user