Spaces:
Sleeping
Sleeping
columns fix
Browse files
app.py
CHANGED
|
@@ -2,42 +2,37 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
|
| 5 |
-
columns_embeddings_col1 = ['Indicator Name']
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
def process_tables(table1_path, table2_path, columns_embeddings_col1, columns_embeddings_col2, harmonization):
|
| 11 |
-
# Assuming process_similarity_results is a function defined in the uploaded functions.py
|
| 12 |
-
# that we've adapted based on previous discussions.
|
| 13 |
-
import functions
|
| 14 |
|
| 15 |
# Load tables
|
| 16 |
table1 = pd.read_csv(table1_path)
|
| 17 |
table2 = pd.read_csv(table2_path)
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
result_final = functions.process_similarity_results(table1, table2, harmonization,columns_embeddings_col1,columns_embeddings_col2)
|
| 22 |
|
| 23 |
-
#
|
| 24 |
result_path = "/mnt/data/result_final.csv"
|
| 25 |
result_final.to_csv(result_path, index=False)
|
|
|
|
| 26 |
return result_path
|
| 27 |
|
| 28 |
-
#
|
| 29 |
iface = gr.Interface(
|
| 30 |
fn=process_tables,
|
| 31 |
inputs=[
|
| 32 |
gr.File(label="Upload Table 1 (Client Indicators or Framework Table)"),
|
| 33 |
gr.File(label="Upload Table 2 (Internal Indicator or Indicator Table)"),
|
| 34 |
-
gr.Checkbox(label="Harmonization Mode", value=True)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
gr.File(label="Download Processed Results")
|
| 38 |
],
|
|
|
|
| 39 |
description="Upload two tables and process them based on the selected parameters. If harmonization, set Table 1 as the Framework Table and Table 2 as the Indicator Table. Otherwise, set Table 1 as the Client Indicators Table and Table 2 as the Internal Indicator Table."
|
| 40 |
)
|
| 41 |
|
| 42 |
iface.launch()
|
| 43 |
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
+
def process_tables(table1_path, table2_path, harmonization, columns_embeddings_col1="Indicator Name", columns_embeddings_col2="Indicator name (leonardo)"):
|
| 7 |
+
import functions # Assuming functions.py has necessary imports and functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Load tables
|
| 10 |
table1 = pd.read_csv(table1_path)
|
| 11 |
table2 = pd.read_csv(table2_path)
|
| 12 |
|
| 13 |
+
# Process the tables using a function from functions.py
|
| 14 |
+
result_final = functions.process_similarity_results(table1, table2, harmonization, columns_embeddings_col1, columns_embeddings_col2)
|
|
|
|
| 15 |
|
| 16 |
+
# Save the result to a CSV file
|
| 17 |
result_path = "/mnt/data/result_final.csv"
|
| 18 |
result_final.to_csv(result_path, index=False)
|
| 19 |
+
|
| 20 |
return result_path
|
| 21 |
|
| 22 |
+
# Define the Gradio interface
|
| 23 |
iface = gr.Interface(
|
| 24 |
fn=process_tables,
|
| 25 |
inputs=[
|
| 26 |
gr.File(label="Upload Table 1 (Client Indicators or Framework Table)"),
|
| 27 |
gr.File(label="Upload Table 2 (Internal Indicator or Indicator Table)"),
|
| 28 |
+
gr.Checkbox(label="Harmonization Mode", value=True),
|
| 29 |
+
gr.Textbox(label="Columns for Embeddings in Table 1", placeholder="Enter column names separated by commas", default="Indicator Name"),
|
| 30 |
+
gr.Textbox(label="Columns for Embeddings in Table 2", placeholder="Enter column names separated by commas", default="Indicator name (leonardo)")
|
|
|
|
| 31 |
],
|
| 32 |
+
outputs="file",
|
| 33 |
description="Upload two tables and process them based on the selected parameters. If harmonization, set Table 1 as the Framework Table and Table 2 as the Indicator Table. Otherwise, set Table 1 as the Client Indicators Table and Table 2 as the Internal Indicator Table."
|
| 34 |
)
|
| 35 |
|
| 36 |
iface.launch()
|
| 37 |
|
| 38 |
+
|