Updates related to data file exports.
This commit is contained in:
@@ -103,7 +103,19 @@ obj_type_kv_li = {
|
||||
'mdl': Event_Badge_Base, 'mdl_default': Event_Badge_Basic_Base, 'mdl_alt': Event_Badge_Basic_Base
|
||||
},
|
||||
'event_presenter': {
|
||||
'tbl': 'event_presenter', 'tbl_default': 'v_event_presenter', 'tbl_update': 'event_presenter', 'mdl': Event_Presenter_Base, 'mdl_default': Event_Presenter_Base, 'mdl_in': Event_Presenter_Base, 'mdl_out': Event_Presenter_Out_Base
|
||||
'tbl': 'event_presenter', 'tbl_default': 'v_event_presenter', 'tbl_update': 'event_presenter', 'mdl': Event_Presenter_Base, 'mdl_default': Event_Presenter_Base, 'mdl_in': Event_Presenter_Base, 'mdl_out': Event_Presenter_Out_Base,
|
||||
'exp_default': [
|
||||
'event_presenter_id_random',
|
||||
# 'account_id_random',
|
||||
'title_names', 'given_name', 'middle_name', 'family_name', 'designations',
|
||||
'professional_title', 'full_name',
|
||||
'affiliations',
|
||||
'email', 'biography',
|
||||
# 'image_li_json', 'social_li_json',
|
||||
'agree',
|
||||
'comments',
|
||||
'enable', 'hide', 'priority', 'sort', 'group', 'notes', 'created_on', 'updated_on',
|
||||
],
|
||||
},
|
||||
} # New 2024-04-23
|
||||
# obj_type_kv_li['example_template'] = {'tbl': 'example_template', 'tbl_default': 'v_example_template', 'tbl_update': 'example_template', 'mdl': Example_Template_Base, 'mdl_in': Example_Template_In_Base, 'mdl_out': Example_Template_Out_Base }
|
||||
|
||||
@@ -382,6 +382,11 @@ def create_export_file(
|
||||
data_dataframe = pandas.DataFrame(data_dict_list)
|
||||
log.debug(data_dataframe)
|
||||
|
||||
missing_cols = [col for col in column_name_li if col not in data_dataframe.columns]
|
||||
if missing_cols:
|
||||
raise KeyError(f"The following columns are not found in the DataFrame: {', '.join(missing_cols)}")
|
||||
|
||||
# Need to deal with this error: KeyError("Not all names specified in 'columns' are found")
|
||||
try:
|
||||
if export_type == 'CSV':
|
||||
log.info('Saving dataframe to CSV file')
|
||||
@@ -390,7 +395,7 @@ def create_export_file(
|
||||
tmp_file_path = os.path.join(subdir_path,filename_w_ext)
|
||||
data_dataframe.to_csv(
|
||||
full_dest_path,
|
||||
# na_rep='NULL',
|
||||
na_rep='NULL',
|
||||
columns=column_name_li,
|
||||
index=False,
|
||||
# errors='ignore',
|
||||
@@ -403,7 +408,7 @@ def create_export_file(
|
||||
# This should ignore unknown columns
|
||||
data_dataframe.to_excel(
|
||||
full_dest_path,
|
||||
# na_rep='NULL',
|
||||
na_rep='NULL',
|
||||
columns=column_name_li,
|
||||
index=False,
|
||||
# engine='openpyxl',
|
||||
|
||||
Reference in New Issue
Block a user