Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,11 +2,19 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import tempfile
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
def extract_contacts(selected_status, selected_sites, contact_type):
|
| 10 |
# Filter accounts
|
| 11 |
filtered_accounts = final_accounts[
|
| 12 |
(final_accounts['OVERALL_STATUS'].isin(selected_status)) &
|
|
@@ -39,14 +47,18 @@ def extract_contacts(selected_status, selected_sites, contact_type):
|
|
| 39 |
|
| 40 |
# Gradio UI
|
| 41 |
with gr.Blocks() as demo:
|
| 42 |
-
gr.Markdown("# 🗂️ Contact Extractor -
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
status_dropdown = gr.CheckboxGroup(
|
| 45 |
-
choices=list(
|
| 46 |
label="Select OVERALL_STATUS"
|
| 47 |
)
|
| 48 |
site_dropdown = gr.CheckboxGroup(
|
| 49 |
-
choices=list(
|
| 50 |
label="Select SITE"
|
| 51 |
)
|
| 52 |
contact_type = gr.Radio(["Active", "Inactive"], label="Contact Type")
|
|
@@ -58,7 +70,7 @@ with gr.Blocks() as demo:
|
|
| 58 |
|
| 59 |
submit_btn.click(
|
| 60 |
extract_contacts,
|
| 61 |
-
inputs=[status_dropdown, site_dropdown, contact_type],
|
| 62 |
outputs=[output_table, download_csv]
|
| 63 |
)
|
| 64 |
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import tempfile
|
| 4 |
|
| 5 |
+
# Preloaded fallback data
|
| 6 |
+
default_accounts = pd.read_csv("accounts.csv")
|
| 7 |
+
default_contacts = pd.read_csv("contacts.csv")
|
| 8 |
+
|
| 9 |
+
def extract_contacts(accounts_file, contacts_file, selected_status, selected_sites, contact_type):
|
| 10 |
+
# Decide source: uploaded or default
|
| 11 |
+
if accounts_file is not None and contacts_file is not None:
|
| 12 |
+
final_accounts = pd.read_csv(accounts_file.name)
|
| 13 |
+
final_contacts = pd.read_csv(contacts_file.name)
|
| 14 |
+
else:
|
| 15 |
+
final_accounts = default_accounts
|
| 16 |
+
final_contacts = default_contacts
|
| 17 |
|
|
|
|
| 18 |
# Filter accounts
|
| 19 |
filtered_accounts = final_accounts[
|
| 20 |
(final_accounts['OVERALL_STATUS'].isin(selected_status)) &
|
|
|
|
| 47 |
|
| 48 |
# Gradio UI
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
+
gr.Markdown("## 🗂️ Contact Extractor - Optional Upload (Stealth Mode)")
|
| 51 |
+
|
| 52 |
+
with gr.Row():
|
| 53 |
+
accounts_file = gr.File(label="Upload Accounts CSV (optional)", file_types=[".csv"])
|
| 54 |
+
contacts_file = gr.File(label="Upload Contacts CSV (optional)", file_types=[".csv"])
|
| 55 |
|
| 56 |
status_dropdown = gr.CheckboxGroup(
|
| 57 |
+
choices=list(default_accounts['OVERALL_STATUS'].unique()),
|
| 58 |
label="Select OVERALL_STATUS"
|
| 59 |
)
|
| 60 |
site_dropdown = gr.CheckboxGroup(
|
| 61 |
+
choices=list(default_accounts['SITE'].unique()),
|
| 62 |
label="Select SITE"
|
| 63 |
)
|
| 64 |
contact_type = gr.Radio(["Active", "Inactive"], label="Contact Type")
|
|
|
|
| 70 |
|
| 71 |
submit_btn.click(
|
| 72 |
extract_contacts,
|
| 73 |
+
inputs=[accounts_file, contacts_file, status_dropdown, site_dropdown, contact_type],
|
| 74 |
outputs=[output_table, download_csv]
|
| 75 |
)
|
| 76 |
|