| import gradio as gr |
| import pandas as pd |
| import os |
|
|
| from functions import process_survey |
|
|
| |
| CHOICES_PATH = "data/Indicators_choices_Default View 18.xlsx" |
| QUESTIONS_PATH = "data/Indicators_questions_Default View 20.xlsx" |
| INDICATORS_PATH = "data/Indicators_indicators_Default view 23.xlsx" |
|
|
| def run_validation(survey_file, uuid): |
| |
| if survey_file.name.endswith('.csv'): |
| survey_df = pd.read_csv(survey_file.name) |
| else: |
| survey_df = pd.read_excel(survey_file.name) |
|
|
| |
| choices_df = pd.read_excel(CHOICES_PATH) |
| questions_df = pd.read_excel(QUESTIONS_PATH) |
| indicators_df = pd.read_excel(INDICATORS_PATH) |
|
|
| |
| |
| indicator_df, questions_df, choice_df, data_all, raw_data, column_strategy_df = f.load_dataframes( |
| indicator_path, |
| questions_path, |
| choice_path, |
| survey_path) |
| |
| return indicator_df, questions_df, choice_df, data_all, raw_data, column_strategy_df |
|
|
| with gr.Blocks() as app: |
| gr.Markdown("## Survey Validation App") |
|
|
| survey_file = gr.File(label="Upload your survey (Excel or CSV)") |
| uuid_box = gr.Textbox(label="UUID", value="AGT.MHVL.0A.202505.0001") |
| run_btn = gr.Button("Run Validation") |
| output = gr.Dataframe(label="Validation Output") |
|
|
| run_btn.click( |
| run_validation, |
| inputs=[survey_file, uuid_box], |
| outputs=indicator_df, questions_df, choice_df, data_all, raw_data, column_strategy_df |
| ) |
|
|
| if __name__ == "__main__": |
| app.launch() |
|
|