File size: 1,032 Bytes
5cf30f9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
import gradio as gr
def download_sheet_df(doc_id, sheet_id=0, header=0):
sheet_url = f'https://docs.google.com/spreadsheets/d/{doc_id}/export?format=csv&gid={sheet_id}'
return pd.read_csv(sheet_url, header=header)
df = download_sheet_df(os.environ["SHEET_ID_SECRET"])
def find_reviews(uid):
review_list = []
try:
for reviewer_n in [1, 2, 3, 4]:
df_u = df[df[f"Reviewer_{reviewer_n}_UID_NUMBER_myucla"].astype(int) == int(uid)].copy()
if len(df_u) == 1 and str(df_u.iloc[0]["Question 1 Response Edited"]) != "nan":
review_list.append(df_u.iloc[0][["Full_Name_myucla", "Question 1 Response Edited"]])
except ValueError:
pass
except Exception as e:
raise e
if len(review_list) == 0:
review_list = pd.DataFrame([{"Error": "UID Not Found"}])
return review_list[:3]
demo = gr.Interface(
fn=find_reviews,
inputs="text",
outputs=gr.Dataframe(headers=["Name", "Presentation Path"]),
)
demo.launch(debug=False) |