afortuny commited on
Commit
2a7742d
·
1 Parent(s): 155059d

columns error 5

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -1,15 +1,25 @@
1
  import gradio as gr
2
  import pandas as pd
 
3
  import functions # Assuming functions.py has necessary imports and functions
4
  import tempfile
5
 
6
 
7
- def process_tables(table1_path, table2_path, harmonization, columns_embeddings_col1="Indicator Name", columns_embeddings_col2="Indicator name (leonardo)"):
8
  # Load tables
9
  table1 = pd.read_excel(table1_path.name)
10
  table2 = pd.read_excel(table2_path.name)
11
 
12
- # Process column names
 
 
 
 
 
 
 
 
 
13
  columns_embeddings_col1 = [col.strip() for col in columns_embeddings_col1.split(',')]
14
  columns_embeddings_col2 = [col.strip() for col in columns_embeddings_col2.split(',')]
15
 
@@ -28,14 +38,17 @@ iface = gr.Interface(
28
  inputs=[
29
  gr.File(label="Upload Table 1 (Client Indicators or Framework Table)"),
30
  gr.File(label="Upload Table 2 (Internal Indicator or Indicator Table)"),
31
- gr.Checkbox(label="Harmonization Mode", value=True),
32
- gr.Textbox(label="Columns for Embeddings in Table 1", placeholder="Enter column names separated by commas", value="Indicator Name"),
33
- gr.Textbox(label="Columns for Embeddings in Table 2", placeholder="Enter column names separated by commas", value="Indicator name (leonardo)")
34
  ],
35
  outputs="file",
36
- 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."
 
 
 
 
37
  )
38
 
39
  iface.launch()
40
 
41
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import json
4
  import functions # Assuming functions.py has necessary imports and functions
5
  import tempfile
6
 
7
 
8
+ def process_tables(table1_path, table2_path, params_file_path):
9
  # Load tables
10
  table1 = pd.read_excel(table1_path.name)
11
  table2 = pd.read_excel(table2_path.name)
12
 
13
+ # Load parameters from the JSON file
14
+ with open(params_file_path.name, 'r') as f:
15
+ params = json.load(f)
16
+
17
+ # Extract parameters
18
+ harmonization = params.get("harmonization", True)
19
+ columns_embeddings_col1 = params.get("columns_embeddings_col1", "Indicator Name")
20
+ columns_embeddings_col2 = params.get("columns_embeddings_col2", "Indicator name (leonardo)")
21
+
22
+ # Process column names into lists
23
  columns_embeddings_col1 = [col.strip() for col in columns_embeddings_col1.split(',')]
24
  columns_embeddings_col2 = [col.strip() for col in columns_embeddings_col2.split(',')]
25
 
 
38
  inputs=[
39
  gr.File(label="Upload Table 1 (Client Indicators or Framework Table)"),
40
  gr.File(label="Upload Table 2 (Internal Indicator or Indicator Table)"),
41
+ gr.File(label="Upload Parameters File (JSON format)")
 
 
42
  ],
43
  outputs="file",
44
+ description=(
45
+ "Upload two tables and a JSON parameters file to process them. The parameters file should include: "
46
+ "'harmonization' (True or False), 'columns_embeddings_col1' (comma-separated column names), "
47
+ "and 'columns_embeddings_col2' (comma-separated column names)."
48
+ )
49
  )
50
 
51
  iface.launch()
52
 
53
 
54
+