Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
from functions import process_survey # Adjust the function name as needed
|
| 6 |
+
|
| 7 |
+
# Paths to the permanent files
|
| 8 |
+
CHOICES_PATH = "/mnt/data/Indicators_choices_Default View 18.xlsx"
|
| 9 |
+
QUESTIONS_PATH = "/mnt/data/Indicators_questions_Default View 20.xlsx"
|
| 10 |
+
INDICATORS_PATH = "/mnt/data/Indicators_indicators_Default view 23.xlsx"
|
| 11 |
+
|
| 12 |
+
def run_validation(survey_file, uuid):
|
| 13 |
+
# Read user survey
|
| 14 |
+
if survey_file.name.endswith('.csv'):
|
| 15 |
+
survey_df = pd.read_csv(survey_file.name)
|
| 16 |
+
else:
|
| 17 |
+
survey_df = pd.read_excel(survey_file.name)
|
| 18 |
+
|
| 19 |
+
# Read permanent datasets
|
| 20 |
+
choices_df = pd.read_excel(CHOICES_PATH)
|
| 21 |
+
questions_df = pd.read_excel(QUESTIONS_PATH)
|
| 22 |
+
indicators_df = pd.read_excel(INDICATORS_PATH)
|
| 23 |
+
|
| 24 |
+
# Pass all inputs to your function (update name/args as needed)
|
| 25 |
+
# For example, if your function is: process_survey(survey_df, choices_df, questions_df, indicators_df, uuid)
|
| 26 |
+
result = process_survey(
|
| 27 |
+
survey_df, choices_df, questions_df, indicators_df, uuid
|
| 28 |
+
)
|
| 29 |
+
# Assume result is a DataFrame, can adjust to return Excel, text, etc.
|
| 30 |
+
return result
|
| 31 |
+
|
| 32 |
+
with gr.Blocks() as app:
|
| 33 |
+
gr.Markdown("## Survey Validation App")
|
| 34 |
+
|
| 35 |
+
survey_file = gr.File(label="Upload your survey (Excel or CSV)")
|
| 36 |
+
uuid_box = gr.Textbox(label="UUID", value="AGT.MHVL.0A.202505.0001")
|
| 37 |
+
run_btn = gr.Button("Run Validation")
|
| 38 |
+
output = gr.Dataframe(label="Validation Output")
|
| 39 |
+
|
| 40 |
+
run_btn.click(
|
| 41 |
+
run_validation,
|
| 42 |
+
inputs=[survey_file, uuid_box],
|
| 43 |
+
outputs=output
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
app.launch()
|