import json from dataclasses import dataclass class ColumnMapping: def apply_json_mapping(self, json_path:str): try: with open(json_path) as json_file: user_config = json.load(json_file) for key, value in user_config.items(): if hasattr(self, key): setattr(self, key, value) except FileNotFoundError: print(f"Column mapping file {json_path} could not be found, using the default mappings") @dataclass class NeoserraColumnNames(ColumnMapping): milestone_attribution_source:str = "Attribution Source" milestone_attribution_statement:str = "Attribution Statement" milestone_affirmation:str = "Affirmation" milestone_date: str = "Milestone Date" attribution_date: str = "Attribution Date" client_id: str = "Client ID" milestone_type: str = "Type" # The value that when seen will cause a milestone to be considered a request and not to be counted requested_ecenter_val: str = "Requested on eCenter" center: str = "Center" milestone_type_name: str = "Milestone Type" business_established_val: str = "Business Established" business_start_impact_val: str = "Business Start Impact" primary_naics: str = "Primary NAICS" naics: str = "NAICs" physical_address_county: str = "Physical Address County" satisfaction_score: str = "Question 1" answers: str = "Answers" event_title: str = "Event Title" primary_training_topic: str = "Primary Training Topic" training_id: str = "Training ID" training_topics: str = "Training Topics" funding_source: str = "Funding Source" attendees_total: str = "Attendees, Total" program_format: str = "Program Format" interval_data_value: str = "Value" reportable:str = "Reportable?" start_date:str = "Start Date" @dataclass class OutColumnNames(ColumnMapping): milestone_documentation_level:str = "Documentation Level" unified_naics: str = "NAICS_CODE" census_pct: str = "Percentage" naics_2: str = "NAICS_2" naics_label: str = "NAICS2022_LABEL" pa_naics_pct: str = "PA NAICs Code Percentage" pasbdc_pct: str = "PASBDC NAICs Code Percentage" census_estab: str = "ESTAB" census_naics: str = "NAICS2022" bls_industry: str = "industry_code" bls_estab: str = "annual_avg_estabs" usda_value: str = "Value" county: str = "County" fips: str = "fips" unique_valid_naics: str = "Unique Valid NAICS Codes" missing_naics: str = "Missing NAICS" total_clients: str = "Total Clients" pct_missing_naics: str = "Percent NAICS Missing" county_out_of_state: str = "County Out of State" is_preplanning: str = "Is Preplanning" attendees_range: str = "Attendees Range" val_documented: str = "Documented" val_affirmation_missing: str = "Affirmation Missing" val_preplanning: str = "Business Start-up/Preplanning" class TrainingCountColumns(ColumnMapping): CENTER = 'Center' TOTAL_EVENTS = 'Total Events' SELECTED_EVENTS = 'Selected Events' PERCENT_SELECTED_EVENTS = 'Percent Selected Events' TOTAL_ATTENDEES = 'Total Attendees' SELECTED_ATTENDEES = 'Selected Attendees' PERCENT_SELECTED_ATTENDEES = 'Percent Selected Attendees' SELECTED_ATTENDEES_NO_FIRST_STEPS = 'Selected Attendees No First Steps' PERCENT_SELECTED_ATTENDEES_NO_FIRST_STEPS = 'Percent Selected Attendees No First Steps' SELECTED_ATTENDEES_NO_FIRST_STEPS_NO_PREPLANNING = 'Selected Attendees No First Steps No Preplanning' PERCENT_SELECTED_ATTENDEES_NO_FIRST_STEPS_NO_PREPLANNING = 'Percent Selected Attendees No First Steps No Preplanning' SELECTED_ATTENDEES_FIRST_STEPS_AND_PREPLANNING = 'Selected Attendees First Steps and Preplanning' PERCENT_SELECTED_ATTENDEES_FIRST_STEPS_AND_PREPLANNING = 'Percent Selected Attendees First Steps and Preplanning' SELECTED_EVENTS_FIRST_STEPS_AND_PREPLANNING = 'Selected Events First Steps and Preplanning' PERCENT_SELECTED_EVENTS_FIRST_STEPS_AND_PREPLANNING = 'Percent Selected Events First Steps and Preplanning' SELECTED_EVENTS_NO_FIRST_STEPS = 'Selected Events No First Steps' PERCENT_SELECTED_EVENTS_NO_FIRST_STEPS = 'Percent Selected Events No First Steps' SELECTED_EVENTS_NO_PREPLANNING_NO_FIRST_STEPS = 'Selected Events No Preplanning No First Steps' PERCENT_SELECTED_EVENTS_NO_PREPLANNING_NO_FIRST_STEPS = 'Percent Selected Events No Preplanning No First Steps' TOTAL_ONDEMAND = 'Total Ondemand' SELECTED_TOTAL_ONDEMAND = 'Selected Total Ondemand' PERCENT_SELECTED_ONDEMAND = 'Percent Selected Ondemand' SELECTED_TOTAL_ONDEMAND_NO_FIRST_STEPS = 'Selected Total Ondemand No First Steps' SELECTED_PERCENT_ONDEMAND_NO_FIRST_STEPS = 'Selected Percent Ondemand No First Steps' SELECTED_TOTAL_ONDEMAND_NO_PREPLANNING_NO_FIRST_STEPS = 'Selected Total Ondemand No Preplanning No First Steps' SELECTED_PERCENT_ONDEMAND_NO_PREPLANNING_NO_FIRST_STEPS = 'Selected Percent Ondemand No Preplanning No First Steps' NEOSERRA_COLUMNS = NeoserraColumnNames() OUT_COLUMNS = OutColumnNames() TRAINING_COUNT_COLUMNS = TrainingCountColumns()