| 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) |
|
|
| |
| |
| result = process_survey( |
| survey_df, choices_df, questions_df, indicators_df, uuid |
| ) |
| |
| return result |
|
|
| 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=output |
| ) |
|
|
| if __name__ == "__main__": |
| app.launch() |
|
|