def display_get_zipcode_attributes(parms): """ * --------------------------------------------------------- * function : display the calculate distance form * * parms : * pytype - address or coords * * returns : * N/A * -------------------------------------------------------- """ zip_attr_form = InputForm( zipcode_atributes_input_id, zipcode_atributes_input_idList, zipcode_atributes_input_labelList, zipcode_atributes_input_typeList, zipcode_atributes_input_placeholderList, zipcode_atributes_input_jsList, zipcode_atributes_input_reqList) zip_attr_form.set_gridwidth(720) zip_attr_form.set_custombwidth(100) zip_attr_form.set_fullparms(True) zip_attr_input_html = "" zip_attr_input_html = zip_attr_form.get_html() zip_attr_heading_html = "<div>Get Zipcode Attributes</div>" gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"] gridhtmls = [zip_attr_heading_html, zip_attr_input_html] print("\n") display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
def display_df_criteria(df_title, df): """ * -------------------------------------------------------------------------- * function : display current df subset form * * parms : * df - dataframe to subset from * filters - filters form * colname - filters column name * * returns : N/A * -------------------------------------------------------- """ col_stats_table = get_column_stats_table(df_title, df) from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm(get_subset_criteria_input_id, get_subset_criteria_input_idList, get_subset_criteria_input_labelList, get_subset_criteria_input_typeList, get_subset_criteria_input_placeholderList, get_subset_criteria_input_jsList, get_subset_criteria_input_reqList) subset_input_form.set_label_note({ 2: [ dfchelp.SUBSET_CRITERIA, "dataframe subset criteria", "subsetcriteriaimageid" ] }) subset_input_form.set_textarea_resize_flag(1, False) subset_input_form.set_textarea_resize_flag(3, False) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(620) subset_input_form.set_custombwidth(110) subset_input_form.set_fullparms(True) subset_input_form.set_custom_font_size("gsselectstring", 14) cfg.set_config_value(get_subset_criteria_input_id + "Parms", [ "", swsm.starting_criteria_preamble, swsm.starting_criteria, swsm.starting_criteria_postamble ]) cfg.set_config_value(get_subset_criteria_input_id + "ParmsProtect", [False, True, False, True]) get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Get Dataframe Subset</div><br></br>" gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"] gridhtmls = [ col_stats_table, get_subset_heading_html, get_subset_input_html ] print("\n") display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def display_saved_subset_sequences(): """ * -------------------------------------------------------------------------- * function : display current saved sequences * * parms : * df - dataframe to subset from * * returns : N/A * -------------------------------------------------------- """ from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm(get_subset_sequences_input_id, get_subset_sequences_input_idList, get_subset_sequences_input_labelList, get_subset_sequences_input_typeList, get_subset_sequences_input_placeholderList, get_subset_sequences_input_jsList, get_subset_sequences_input_reqList) selectDicts = [] sequences = swsm.get_sequences_list() if (len(sequences) > 0): seqdict = {"default": sequences[0], "list": sequences} else: seqdict = { "default": "no saved sequences", "list": ["no saved sequences"] } selectDicts.append(seqdict) subsetact = {"default": "Auto Run", "list": ["Auto Run", "Manual Run"]} selectDicts.append(subsetact) get_select_defaults(subset_input_form, get_subset_sequences_input_form[0], get_subset_sequences_input_form[1], get_subset_sequences_input_form[3], selectDicts) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(680) subset_input_form.set_custombwidth(140) subset_input_form.set_fullparms(True) get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Run Saved Subset Sequence</div><br>" gridclasses = ["dfcleanser-common-grid-header", "dfc-main"] gridhtmls = [get_subset_heading_html, get_subset_input_html] print("\n") display_generic_grid("sw-utils-subset-main-wrapper", gridclasses, gridhtmls)
def display_sequence_save_subset(df_title, df, auto=False): """ * -------------------------------------------------------------------------- * function : display current df subset run * * parms : * df - dataframe to subset from * * returns : N/A * -------------------------------------------------------- """ df_stats_table = get_df_stats_table(df_title, df) df_cols_table = get_column_stats_table(df_title, df) from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm( get_saved_save_input_id, get_saved_save_input_idList, get_saved_save_input_labelList, get_saved_save_input_typeList, get_saved_save_input_placeholderList, get_saved_save_input_jsList, get_saved_save_input_reqList) selectDicts = [] dropsel = {"default": "False", "list": ["True", "False"]} selectDicts.append(dropsel) get_select_defaults(subset_input_form, get_saved_save_input_id, get_saved_save_input_idList, get_saved_save_input_typeList, selectDicts) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(680) subset_input_form.set_custombwidth(140) subset_input_form.set_fullparms(True) cfg.set_config_value( get_saved_save_input_id + "Parms", [df_title, "./" + df_title + ".csv", df_title, "False"]) cfg.drop_config_value(get_saved_save_input_id + "ParmsProtect") get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Save Dataframe Subset</div><br>" gridclasses = [ "dfc-top", "dfc-main", "dfcleanser-common-grid-header", "dfc-bottom" ] gridhtmls = [ df_stats_table, df_cols_table, get_subset_heading_html, get_subset_input_html ] print("\n") display_generic_grid("sw-utils-subset-run-wrapper", gridclasses, gridhtmls)
def display_offline(): """ * -------------------------------------------------------------------------- * function : display offline toggle mode * * parms : * N/A * * returns : N/A * -------------------------------------------------------- """ from dfcleanser.common.html_widgets import InputForm dfmanager_input_form = InputForm( dfmgr_offline_input_id, dfmgr_offline_input_idList, dfmgr_offline_input_labelList, dfmgr_offline_input_typeList, dfmgr_offline_input_placeholderList, dfmgr_offline_input_jsList, dfmgr_offline_input_reqList) selectDicts = [] if (sysm.get_dfc_run_offline_status()): stat = "True" else: stat = "False" offline_mode = {"default": stat, "list": ["False", "True"]} selectDicts.append(offline_mode) get_select_defaults(dfmanager_input_form, dfmgr_offline_input_id, dfmgr_offline_input_idList, dfmgr_offline_input_typeList, selectDicts) dfmanager_input_form.set_shortForm(True) dfmanager_input_form.set_gridwidth(480) dfmanager_input_form.set_custombwidth(100) dfmanager_input_form.set_fullparms(True) dfmgr_input_html = dfmanager_input_form.get_html() dfmgr_heading_html = "<div>Run dfc Offline Manager</div>" gridclasses = ["dfcleanser-common-grid-header", "dfc-main"] gridhtmls = [dfmgr_heading_html, dfmgr_input_html] print("\n") if (cfg.get_dfc_mode() == cfg.INLINE_MODE): display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses, gridhtmls) else: display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses, gridhtmls, True) from dfcleanser.common.display_utils import display_pop_up_buffer display_pop_up_buffer()
def display_get_cities_for_state(parms): state_cities_form = InputForm( state_cities_input_id, state_cities_input_idList, state_cities_input_labelList, state_cities_input_typeList, state_cities_input_placeholderList, state_cities_input_jsList, state_cities_input_reqList) selectDicts = [] from dfcleanser.sw_utilities.sw_utility_model import get_Dict states_dict = get_Dict("US_States_and_Territories") state_keys = list(states_dict.keys()) state_keys.sort() states_list = [] for i in range(len(state_keys)): states_list.append( str(state_keys[i]) + " : " + str(states_dict.get(state_keys[i]))) state_sel = {"default": states_list[0], "list": states_list} selectDicts.append(state_sel) get_select_defaults(state_cities_form, state_cities_input_id, state_cities_input_idList, state_cities_input_typeList, selectDicts) state_cities_form.set_gridwidth(720) state_cities_form.set_custombwidth(100) state_cities_form.set_fullparms(True) state_cities_input_html = "" state_cities_input_html = state_cities_form.get_html() state_cities_heading_html = "<div>Get State Cities</div>" gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"] gridhtmls = [state_cities_heading_html, state_cities_input_html] print("\n") display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
def display_add_df_input(): """ * -------------------------------------------------------------------------- * function : add a dataframe to the dfc list * * parms : * * returns : N/A * -------------------------------------------------------- """ from dfcleanser.common.html_widgets import InputForm dfmanager_input_form = InputForm( dfmgr_add_input_id, dfmgr_add_input_idList, dfmgr_add_input_labelList, dfmgr_add_input_typeList, dfmgr_add_input_placeholderList, dfmgr_add_input_jsList, dfmgr_add_input_reqList) dfmanager_input_form.set_shortForm(True) dfmanager_input_form.set_gridwidth(480) dfmanager_input_form.set_custombwidth(70) dfmanager_input_form.set_fullparms(True) dfmgr_input_html = dfmanager_input_form.get_html() dfmgr_heading_html = "<div>Add df to dfc dataframe Manager</div>" gridclasses = ["dfcleanser-common-grid-header", "dfc-main"] gridhtmls = [dfmgr_heading_html, dfmgr_input_html] print("\n") if (cfg.get_dfc_mode() == cfg.INLINE_MODE): display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses, gridhtmls) else: display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses, gridhtmls, True) from dfcleanser.common.display_utils import display_pop_up_buffer display_pop_up_buffer()
def display_funcs(): """ * ------------------------------------------------------------------------ * function : display the dfc funcs start form * * parms : * * ------------------------------------------------------------------------- """ list_funcs_input_form = InputForm( build_funcs_utility_input_id, build_funcs_utility_input_idList, build_funcs_utility_input_labelList, build_funcs_utility_input_typeList, build_funcs_utility_input_placeholderList, build_funcs_utility_input_jsList, build_funcs_utility_input_reqList) selectDicts = [] from dfcleanser.sw_utilities.sw_utility_genfunc_model import get_genfunc_list gen_funcs = get_genfunc_list() default_func = gen_funcs[0] funcssel = { "default": default_func, "list": gen_funcs, "callback": "select_gen_func" } selectDicts.append(funcssel) from dfcleanser.common.common_utils import get_select_defaults get_select_defaults(list_funcs_input_form, build_funcs_utility_input_id, build_funcs_utility_input_idList, build_funcs_utility_input_typeList, selectDicts) list_funcs_input_form.set_gridwidth(700) list_funcs_input_form.set_custombwidth(120) list_funcs_input_form.set_fullparms(True) from dfcleanser.sw_utilities.sw_utility_genfunc_model import reservedfunctionsmodule from dfcleanser.sw_utilities.sw_utility_genfunc_functions import get_generic_function_code func_code = get_generic_function_code(default_func) cfg.set_config_value(build_funcs_utility_input_id + "Parms", [default_func, reservedfunctionsmodule, func_code]) cfg.set_config_value(build_funcs_utility_input_id + "ParmsProtect", [False, True, True]) help_note = "Generic functions help note'" from dfcleanser.common.common_utils import get_help_note_html list_funcs_notes_html = get_help_note_html(help_note, 100, None, None) list_funcs_html = "" list_funcs_html = list_funcs_input_form.get_html() list_funcs_title_html = "<div>Generic dfc Functions</div><br></br>" gridclasses = ["dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"] gridhtmls = [list_funcs_title_html, list_funcs_html, list_funcs_notes_html] print("\n") display_generic_grid("sw-utils-listdict-wrapper", gridclasses, gridhtmls)
def display_list_dict(stype, keyValue=None): """ * ------------------------------------------------------------------------ * function : display the dict or list start form * * parms : * id - list or dict * keyValue - dict or list name * * ------------------------------------------------------------------------- """ #print("display_list_dict",stype,keyValue) if (stype == swum.DICT_ID): list_dict_form = build_dict_utility_input_form else: list_dict_form = build_list_utility_input_form list_dict_input_form = InputForm(list_dict_form[0], list_dict_form[1], list_dict_form[2], list_dict_form[3], list_dict_form[4], list_dict_form[5], list_dict_form[6]) selectDicts = [] if (stype == swum.DICT_ID): from dfcleanser.sw_utilities.sw_utility_model import get_dicts_names, DFC_CREATED dict_names = get_dicts_names(DFC_CREATED) if (keyValue is None): def_dict = dict_names[0] else: def_dict = keyValue #print("def_dict",def_dict,keyValue) dictssel = { "default": def_dict, "list": dict_names, "callback": "select_dict" } seldict = swum.get_Dict(def_dict, DFC_CREATED) keys = list(seldict.keys()) if ((def_dict == "Country_Codes") or (def_dict == "Language_Codes")): keys.sort() seldict = swum.get_pretty_dict(seldict, keys) else: from dfcleanser.sw_utilities.sw_utility_model import get_lists_names, DFC_CREATED list_names = get_lists_names(DFC_CREATED) if (keyValue is None): def_list = list_names[0] else: def_list = keyValue dictssel = { "default": def_list, "list": list_names, "callback": "select_list" } sellist = str(swum.get_List(def_list, DFC_CREATED)) selectDicts.append(dictssel) from dfcleanser.common.common_utils import get_select_defaults get_select_defaults(list_dict_input_form, list_dict_form[0], list_dict_form[1], list_dict_form[3], selectDicts) list_dict_input_form.set_gridwidth(700) list_dict_input_form.set_custombwidth(120) list_dict_input_form.set_fullparms(True) if (stype == swum.DICT_ID): selparms = [def_dict, seldict] cfg.set_config_value(build_dict_utility_input_id + "Parms", selparms) cfg.set_config_value(build_dict_utility_input_id + "ParmsProtect", [False, True]) help_note = "To retrieve a dict in python from dfcleanser.sw_utiliities.sw_utility.model call 'get_Dict(dictname)'.</br>To add a dict in python from dfcleanser.sw_utiliities.sw_utility.model call 'add_Dict(dictname,newdict)'" else: selparms = [def_list, sellist] cfg.set_config_value(build_list_utility_input_id + "Parms", selparms) cfg.set_config_value(build_list_utility_input_id + "ParmsProtect", [False, True]) help_note = "To retrieve a list in python from dfcleanser.sw_utiliities.sw_utility.model call 'get_List(listname)'.</br>To add a list in python from dfcleanser.sw_utiliities.sw_utility.model call 'add_List(listtname,newlist)'" from dfcleanser.common.common_utils import get_help_note_html listdict_notes_html = get_help_note_html(help_note, 100, None, None) list_dictcustom_html = "" list_dictcustom_html = list_dict_input_form.get_html() if (stype == swum.DICT_ID): list_title_html = "<div>dfc Dicts</div><br></br>" cfg.drop_config_value(build_dict_utility_input_id + "Parms") else: list_title_html = "<div>dfc Lists</div><br></br>" cfg.drop_config_value(build_list_utility_input_id + "Parms") gridclasses = ["dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"] gridhtmls = [list_title_html, list_dictcustom_html, listdict_notes_html] print("\n") display_generic_grid("sw-utils-listdict-wrapper", gridclasses, gridhtmls)
def display_get_cities_for_county(parms): if (parms is None): fparms = cfg.get_config_value(county_cities_input_id + "Parms") if (not (fparms is None)): stateid = fparms[0] else: stateid = None else: fparms = get_parms_for_input(parms, county_cities_input_idList) stateid = fparms[0] cfg.set_config_value(county_cities_input_id + "Parms", fparms) county_cities_form = InputForm( county_cities_input_id, county_cities_input_idList, county_cities_input_labelList, county_cities_input_typeList, county_cities_input_placeholderList, county_cities_input_jsList, county_cities_input_reqList) selectDicts = [] from dfcleanser.sw_utilities.sw_utility_model import get_Dict states_dict = get_Dict("US_States_and_Territories") state_keys = list(states_dict.keys()) state_keys.sort() states_list = [] for i in range(len(state_keys)): states_list.append( str(state_keys[i]) + " : " + str(states_dict.get(state_keys[i]))) if (stateid is None): state_def = states_list[0] else: state_def = stateid state_sel = { "default": state_def, "list": states_list, "callback": "change_state_for_counties" } selectDicts.append(state_sel) state_id = state_def[:2] counties_list = suzm.get_counties_for_state(state_id) county_sel = {"default": counties_list[0], "list": counties_list} selectDicts.append(county_sel) get_select_defaults(county_cities_form, county_cities_input_id, county_cities_input_idList, county_cities_input_typeList, selectDicts) county_cities_form.set_gridwidth(720) county_cities_form.set_custombwidth(100) county_cities_form.set_fullparms(True) county_cities_input_html = "" county_cities_input_html = county_cities_form.get_html() county_cities_heading_html = "<div>Get County Cities</div>" gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"] gridhtmls = [county_cities_heading_html, county_cities_input_html] print("\n") display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
def display_manual_df_subset_setup(sequence_title, input_df_title, colnames_list, cols_action, stepid): """ * -------------------------------------------------------------------------- * function : display current manual df subset form * * parms : * df - dataframe to subset from * filters - filters form * colname - filters column name * * returns : N/A * -------------------------------------------------------- """ df = swsm.get_current_subset_df() col_stats_table = get_column_stats_table(input_df_title, df) from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm(get_manual_input_id, get_manual_input_idList, get_manual_input_labelList, get_manual_input_typeList, get_manual_input_placeholderList, get_manual_input_jsList, get_manual_input_reqList) selectDicts = [] dataframes = { "default": input_df_title, "list": [input_df_title] } #cfg.get_dfc_dataframes_select_list(cfg.SWDFSubsetUtility_ID) selectDicts.append(dataframes) current_df = df #cfg.get_dfc_dataframe_df(input_df_title) colnames = current_df.columns.tolist() cols_name_list = [" "] for i in range(len(colnames)): cols_name_list.append(colnames[i]) cnames = { "default": cols_name_list[0], "list": cols_name_list, "callback": "change_subset_cols" } selectDicts.append(cnames) if (cols_action == "Keep"): subssel = {"default": "Keep", "list": ["Keep", "Drop"]} else: subssel = {"default": "Drop", "list": ["Keep", "Drop"]} selectDicts.append(subssel) get_select_defaults(subset_input_form, get_manual_input_form[0], get_manual_input_form[1], get_manual_input_form[3], selectDicts) if (len(colnames_list) > 0): cnames = str(colnames_list) else: cnames = "" cfg.set_config_value(get_manual_input_id + "Parms", ["", cnames, "", cols_action]) cfg.set_config_value(get_manual_input_id + "ParmsProtect", [True, False, False, False]) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(680) subset_input_form.set_custombwidth(140) subset_input_form.set_fullparms(True) get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Run Subset Sequence '" + str( sequence_title) + "' Step " + str(stepid) + "</div><br></br>" gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"] gridhtmls = [ col_stats_table, get_subset_heading_html, get_subset_input_html ] print("\n") display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def display_process_subset(): """ * -------------------------------------------------------------------------- * function : display current df subset form * * parms : * df - dataframe to subset from * * returns : N/A * -------------------------------------------------------- """ current_step = swsm.get_current_subset_step() dftitle = current_step.get_output_subset_df_title() subset_df = swsm.get_current_subset_df() df_stats_table = get_df_stats_table(dftitle, subset_df) df_cols_table = get_column_stats_table(dftitle, subset_df) from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm( get_subset_run_input_id, get_subset_run_input_idList, get_subset_run_input_labelList, get_subset_run_input_typeList, get_subset_run_input_placeholderList, get_subset_run_input_jsList, get_subset_run_input_reqList) selectDicts = [] colnames = subset_df.columns.tolist() cols_name_list = [" "] for i in range(len(colnames)): cols_name_list.append(colnames[i]) cnames = { "default": cols_name_list[0], "list": cols_name_list, "callback": "change_run_subset_cols" } selectDicts.append(cnames) subssel = {"default": "Keep", "list": ["Keep", "Drop"]} selectDicts.append(subssel) savesel = {"default": "True", "list": ["True", "False"]} selectDicts.append(savesel) get_select_defaults(subset_input_form, get_subset_run_input_form[0], get_subset_run_input_form[1], get_subset_run_input_form[3], selectDicts) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(680) subset_input_form.set_custombwidth(90) subset_input_form.set_fullparms(True) cfg.set_config_value(get_subset_run_input_id + "Parms", [dftitle, "", "", ""]) cfg.set_config_value(get_subset_run_input_id + "ParmsProtect", [True, False, False, False]) get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Process Dataframe Subset</div><br>" gridclasses = [ "dfc-top", "dfc-main", "dfcleanser-common-grid-header", "dfc-bottom" ] gridhtmls = [ df_stats_table, df_cols_table, get_subset_heading_html, get_subset_input_html ] print("\n") display_generic_grid("sw-utils-subset-run-wrapper", gridclasses, gridhtmls)
def display_df_subset_setup(): """ * -------------------------------------------------------------------------- * function : display current df subset form * * parms : * df - dataframe to subset from * filters - filters form * colname - filters column name * * returns : N/A * -------------------------------------------------------- """ df_title = cfg.get_config_value(cfg.CURRENT_SUBSET_DF) df = cfg.get_dfc_dataframe_df(df_title) col_stats_table = get_column_stats_table(df_title, df) from dfcleanser.common.html_widgets import InputForm subset_input_form = InputForm(get_subset_input_id, get_subset_input_idList, get_subset_input_labelList, get_subset_input_typeList, get_subset_input_placeholderList, get_subset_input_jsList, get_subset_input_reqList) selectDicts = [] dataframes = cfg.get_dfc_dataframes_select_list(cfg.SWDFSubsetUtility_ID) selectDicts.append(dataframes) current_df = cfg.get_current_chapter_df(cfg.SWDFSubsetUtility_ID) colnames = current_df.columns.tolist() cols_name_list = [" "] for i in range(len(colnames)): cols_name_list.append(colnames[i]) cnames = { "default": cols_name_list[0], "list": cols_name_list, "callback": "change_subset_cols" } selectDicts.append(cnames) subssel = {"default": "Keep", "list": ["Keep", "Drop"]} selectDicts.append(subssel) get_select_defaults(subset_input_form, get_subset_input_form[0], get_subset_input_form[1], get_subset_input_form[3], selectDicts) subset_input_form.set_shortForm(False) subset_input_form.set_gridwidth(680) subset_input_form.set_custombwidth(140) subset_input_form.set_fullparms(True) get_subset_input_html = subset_input_form.get_html() get_subset_heading_html = "<div>Get Dataframe Subset</div><br></br>" gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"] gridhtmls = [ col_stats_table, get_subset_heading_html, get_subset_input_html ] print("\n") display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def get_df_list_html(title): """ * -------------------------------------------------------------------------- * function : get the html for list of dfc dataframes * * parms : * N/A * * returns : N/A * -------------------------------------------------------- """ fparms = [] if (title is None): if (cfg.is_a_dfc_dataframe_loaded()): df_titles = cfg.get_dfc_dataframes_titles_list() fparms = [ df_titles[0], str(len(cfg.get_dfc_dataframe_df(df_titles[0]))), str(len(cfg.get_dfc_dataframe_df(df_titles[0]).columns)), cfg.get_dfc_dataframe_notes(df_titles[0]) ] else: fparms = ["", "", "", ""] else: if (cfg.is_a_dfc_dataframe_loaded()): dfc_df = cfg.get_dfc_dataframe(title) if (dfc_df is None): fparms = ["", "", "", ""] else: fparms = [ title, str(len(cfg.get_dfc_dataframe_df(title))), str(len(cfg.get_dfc_dataframe_df(title).columns)), cfg.get_dfc_dataframe_notes(title) ] else: fparms = ["", "", "", ""] parmsProtect = [False, True, True, False] cfg.set_config_value(dfmgr_input_id + "Parms", fparms) cfg.set_config_value(dfmgr_input_id + "ParmsProtect", parmsProtect) dfmanager_input_form = InputForm(dfmgr_input_id, dfmgr_input_idList, dfmgr_input_labelList, dfmgr_input_typeList, dfmgr_input_placeholderList, dfmgr_input_jsList, dfmgr_input_reqList) selectDicts = [] df_titles = cfg.get_dfc_dataframes_titles_list() #if(df_titles is None) : if (not (cfg.is_a_dfc_dataframe_loaded())): dfs = {"default": " ", "list": [" "]} else: dfs = { "default": str(fparms[0]), "list": df_titles, "callback": "select_new_df" } selectDicts.append(dfs) get_select_defaults(dfmanager_input_form, dfmgr_input_id, dfmgr_input_idList, dfmgr_input_typeList, selectDicts) dfmanager_input_form.set_shortForm(True) dfmanager_input_form.set_gridwidth(480) dfmanager_input_form.set_custombwidth(90) dfmanager_input_form.set_fullparms(True) dfmgr_input_html = dfmanager_input_form.get_html() return (dfmgr_input_html)
def display_dc_pandas_export_sql_inputs(fId, dbId, dbconparms, exportparms=None): """ * -------------------------------------------------------------------------- * function : display pandas sql export form * * parms : * fid - export type * dbid - database id * dbconparms - db connector parms * exportparms - export parms * * returns : N/A * -------------------------------------------------------- """ opstat = opStatus() opstatStatus = True listHtml = "" dbid = int(dbId) fid = int(fId) fparms = None if (fid == 0): dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY) from dfcleanser.data_import.data_import_widgets import ( get_table_names, TABLE_NAMES, get_rows_html) tablelist = get_table_names(dbid, opstat) listHtml = get_rows_html(tablelist, TABLE_NAMES, True) elif (fid == 1): fparms = get_parms_for_input(exportparms, pandas_export_sqltable_idList) dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY) cfg.set_config_value(pandas_export_sqltable_id + "Parms", fparms) if (len(fparms[0]) > 0): from dfcleanser.data_import.data_import_widgets import ( get_column_names, get_rows_html) from dfcleanser.data_import.data_import_model import COLUMN_NAMES columnlist = get_column_names(dbid, fparms[1], opstat) listHtml = get_rows_html(columnlist, COLUMN_NAMES, True) else: opstat.set_status(False) opstat.set_errorMsg("No Table Selected") elif (fid == 2): cfg.set_config_value(cfg.CURRENT_DB_ID_KEY, dbid) dbcondict = {} if (not (dbconparms == None)): parse_connector_parms(dbconparms, dbid, dbcondict) else: conparms = get_stored_con_Parms(dbid) parse_connector_parms(conparms, dbid, dbcondict) listHtml = get_db_connector_list(dbid, dbcondict) if (not (opstat.get_status())): dbcondict = {} conparms = get_stored_con_Parms(dbid) parse_connector_parms(conparms, dbid, dbcondict) listHtml = get_db_connector_list(dbid, dbcondict) opstatStatus = opstat.get_status() opstatErrormsg = opstat.get_errorMsg() opstat.set_status(True) if (opstat.get_status()): export_sql_input_form = InputForm( pandas_export_sqltable_id, pandas_export_sqltable_idList, pandas_export_sqltable_labelList, pandas_export_sqltable_typeList, pandas_export_sqltable_placeholderList, pandas_export_sqltable_jsList, pandas_export_sqltable_reqList) selectDicts = [] df_list = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID) selectDicts.append(df_list) exists = {"default": "fail", "list": ["fail", "replace", "append"]} selectDicts.append(exists) index = {"default": "True", "list": ["True", "False"]} selectDicts.append(index) get_select_defaults(export_sql_input_form, pandas_export_sqltable_id, pandas_export_sqltable_idList, pandas_export_sqltable_typeList, selectDicts) export_sql_input_form.set_shortForm(False) export_sql_input_form.set_gridwidth(680) export_sql_input_form.set_custombwidth(125) export_sql_input_form.set_fullparms(True) export_sql_input_html = "" export_sql_input_html = export_sql_input_form.get_html() export_sql_heading_html = "<div>" + get_pandas_export_input_title( dem.SQLTABLE_EXPORT, dbid) + "</div><br>" if (not (exportparms == None)): cfg.set_config_value(pandas_export_sqltable_id + "Parms", fparms) gridclasses = [ "dfcleanser-common-grid-header", "dfc-left", "dfc-right" ] gridhtmls = [export_sql_heading_html, listHtml, export_sql_input_html] display_generic_grid("data-import-sql-table-wrapper", gridclasses, gridhtmls) if (not (opstatStatus)): opstat.set_status(opstatStatus) opstat.set_errorMsg(opstatErrormsg) display_exception(opstat)
def display_dc_export_forms(exid, detid=0, notes=False): """ * -------------------------------------------------------------------------- * function : display pandas export input forms * * parms : * exid - export type * detid - detail id * notes - notes flag * * returns : N/A * -------------------------------------------------------- """ clear_output() # add the main import task bar if (exid == dem.EXPORT_TB_ONLY): display_export_main_taskbar() cfg.display_data_select_df(cfg.DataExport_ID) else: if (cfg.is_a_dfc_dataframe_loaded()): # add the pandas import task bar or pandas details form if ((exid == dem.EXPORT_PANDAS_TB_ONLY) or (exid == dem.EXPORT_PANDAS_TB_PLUS_DETAILS)): # add the pandas export details form if (exid == dem.EXPORT_PANDAS_TB_PLUS_DETAILS): if (detid == dem.SQLTABLE_EXPORT): import dfcleanser.common.db_utils as dbutils cfg.drop_config_value(pandas_export_sqltable_id + "Parms") dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY) if (dbid == None): cfg.set_config_value(cfg.CURRENT_DB_ID_KEY, dbutils.MySql) conparms = cfg.get_config_value( dbutils.MYSQL_DBCON_PARMS) if (conparms == None): conparms = [ "", "", "", "", dbutils.pymysql_library ] elif (dbid == dbutils.MySql): conparms = cfg.get_config_value( dbutils.MYSQL_DBCON_PARMS) if (conparms == None): conparms = [ "", "", "", "", dbutils.pymysql_library ] elif (dbid == dbutils.MS_SQL_Server): conparms = cfg.get_config_value( dbutils.MSSQL_DBCON_PARMS) if (conparms == None): conparms = [ "", "", "", "", dbutils.pyodbc_library ] elif (dbid == dbutils.SQLite): conparms = cfg.get_config_value( dbutils.SQLITE_DBCON_PARMS) if (conparms == None): conparms = ["", dbutils.sqlite3_library] elif (dbid == dbutils.Postgresql): conparms = cfg.get_config_value( dbutils.POSTGRESQL_DBCON_PARMS) if (conparms == None): conparms = [ "", "", "", "", dbutils.psycopg2_library ] elif (dbid == dbutils.Oracle): conparms = cfg.get_config_value( dbutils.ORACLE_DBCON_PARMS) if (conparms == None): conparms = [ "", "", "", dbutils.cx_oracle_library ] elif (dbid == dbutils.Custom): conparms = cfg.get_config_value( dbutils.CUSTOM_DBCON_PARMS) if (conparms == None): conparms = [""] dbutils.display_db_connector_inputs( cfg.get_config_value(cfg.CURRENT_DB_ID_KEY), conparms, dbutils.SQL_EXPORT) else: display_export_main_taskbar() pandas_export_form = get_pandas_export_input_form( detid) if (cfg.get_dfc_mode() == cfg.INLINE_MODE): pandas_export_form.set_shortForm(True) pandas_export_form.set_gridwidth(640) pandas_export_form.set_custombwidth(110) else: pandas_export_form.set_gridwidth(480) pandas_export_form.set_custombwidth(100) pandas_input_html = "" pandas_input_html = pandas_export_form.get_html() pandas_input_heading_html = "<div>" + get_pandas_export_input_title( detid) + "</div>" gridclasses = [ "dfcleanser-common-grid-header", "dfc-footer" ] gridhtmls = [ pandas_input_heading_html, pandas_input_html ] if (cfg.get_dfc_mode() == cfg.INLINE_MODE): display_generic_grid("data-import-wrapper", gridclasses, gridhtmls) else: display_generic_grid("data-import-pop-up-wrapper", gridclasses, gridhtmls) else: display_pandas_export_taskbar() elif (exid == dem.EXPORT_CUSTOM_ONLY): print("dem.EXPORT_PANDAS_TB_ONLY") # add the custom import form exportCustomDetailsForm = InputForm( custom_export_id, custom_export_idList, custom_export_labelList, custom_export_typeList, custom_export_placeholderList, custom_export_jsList, custom_export_reqList) if (notes): customNotes = [ "To create custom export code in the code cell below hit 'New Custom Export'", " (enter and test export in the code cell below)", " (leave the '# custom export' comment line in the code cell", " (call dfcleanser.common.cfg.get_dfc_dataframe_df() to get the current dataframe)", "To run the export code in the Custom Export Code box hit 'Run Custom Export' button", " (only the code in the Custom Export Code box is run and stored for scripting)", "Once import successful hit 'Save Custom Import' button to store import code for future retrieval", "To drop the custom export code and clear the Custom Export Code box hit 'Drop Custom Export' button" ] print("\n") display_inline_help(customNotes, 92) selectDicts = [] df_list = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID) selectDicts.append(df_list) flags = {"default": "False", "list": ["True", "False"]} selectDicts.append(flags) get_select_defaults(exportCustomDetailsForm, custom_export_id, custom_export_idList, custom_export_typeList, selectDicts) if (cfg.get_dfc_mode() == cfg.INLINE_MODE): exportCustomDetailsForm.set_shortForm(True) exportCustomDetailsForm.set_gridwidth(640) exportCustomDetailsForm.set_custombwidth(110) else: exportCustomDetailsForm.set_gridwidth(480) exportCustomDetailsForm.set_custombwidth(100) exportCustomDetailsForm.set_fullparms(True) from dfcleanser.common.html_widgets import new_line custom_code = "# add USER CODE to export the df" + new_line + new_line custom_code = ( custom_code + "from dfcleanser.common.cfg import get_dfc_dataframe" + new_line) custom_code = (custom_code + "df = get_dfc_dataframe_df(dataframe_title)" + new_line + new_line) custom_code = (custom_code + "# USER CODE" + new_line) cfg.set_config_value(custom_export_id + "Parms", ["", custom_code, ""]) custom_export_html = "" custom_export_html = exportCustomDetailsForm.get_html() custom_export_heading_html = "<div>Custom Export</div><br>" gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"] gridhtmls = [custom_export_heading_html, custom_export_html] if (cfg.get_dfc_mode() == cfg.INLINE_MODE): display_generic_grid("data-import-wrapper", gridclasses, gridhtmls) else: display_generic_grid("data-import-pop-up-wrapper", gridclasses, gridhtmls) else: display_export_main_taskbar() cfg.display_data_select_df(cfg.DataExport_ID) cfg.display_no_dfs(cfg.DataExport_ID)