Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import fitz
|
4 |
import pandas as pd
|
5 |
|
6 |
-
def create_excel(doc):
|
7 |
HEADERS = ['TR [min]','Nome','Area','Fator Capacidade','Pratos Teóricos','Sinal-ruído (USP)','Resolução','Assimetría','Altura','Pureza']
|
8 |
LIMITS = [(17,50),(50,130),(130,184),(184,240),(240,311),(311,360),(330,418),(400,487),(450,533),(500,600)]
|
9 |
# LIMITS will be used to correctly identify to which block the data pertains
|
@@ -48,16 +48,16 @@ def create_excel(doc):
|
|
48 |
# SHOW THE RECOVERED DATA
|
49 |
#print(data)
|
50 |
df_table = pd.DataFrame.from_dict(data)
|
51 |
-
df_table.to_excel(
|
52 |
|
53 |
def upload_file(filepath):
|
54 |
-
print(filepath)
|
55 |
name = Path(filepath).name
|
|
|
56 |
# load pdf
|
57 |
doc = fitz.open(filepath)
|
58 |
-
create_excel(doc)
|
59 |
# now create the excel file
|
60 |
-
return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download
|
61 |
|
62 |
def download_file():
|
63 |
return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|
|
|
3 |
import fitz
|
4 |
import pandas as pd
|
5 |
|
6 |
+
def create_excel(doc,name_excel):
|
7 |
HEADERS = ['TR [min]','Nome','Area','Fator Capacidade','Pratos Teóricos','Sinal-ruído (USP)','Resolução','Assimetría','Altura','Pureza']
|
8 |
LIMITS = [(17,50),(50,130),(130,184),(184,240),(240,311),(311,360),(330,418),(400,487),(450,533),(500,600)]
|
9 |
# LIMITS will be used to correctly identify to which block the data pertains
|
|
|
48 |
# SHOW THE RECOVERED DATA
|
49 |
#print(data)
|
50 |
df_table = pd.DataFrame.from_dict(data)
|
51 |
+
df_table.to_excel(name_excel, index=False)
|
52 |
|
53 |
def upload_file(filepath):
|
|
|
54 |
name = Path(filepath).name
|
55 |
+
excel_name = Path(filepath).stem + ".xlsx"
|
56 |
# load pdf
|
57 |
doc = fitz.open(filepath)
|
58 |
+
create_excel(doc,excel_name)
|
59 |
# now create the excel file
|
60 |
+
return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {excel_name}", value=excel_name, visible=True)]
|
61 |
|
62 |
def download_file():
|
63 |
return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]
|