Spaces:
Build error
Build error
neerajkalyank
commited on
Commit
•
d7a232b
1
Parent(s):
d577e8f
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,39 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from toshiba import extract_toshiba_data
|
|
|
3 |
from bhel import extract_bhel_data
|
4 |
|
5 |
def extract_data(pdf_file, company):
|
|
|
6 |
if company == 'Toshiba':
|
|
|
7 |
return extract_toshiba_data(pdf_file)
|
|
|
8 |
elif company == 'BHEL':
|
|
|
9 |
return extract_bhel_data(pdf_file)
|
|
|
10 |
else:
|
|
|
11 |
raise ValueError("Unsupported company format")
|
12 |
|
13 |
company_options = ['Toshiba', 'BHEL']
|
|
|
14 |
interface = gr.Interface(
|
|
|
15 |
fn=extract_data,
|
|
|
16 |
inputs=[gr.File(label="Upload PDF"), gr.Dropdown(choices=company_options, label="Select Company")],
|
|
|
17 |
outputs=gr.File(label="Download Extracted Data as Excel"),
|
|
|
18 |
title="PDF Data Extractor for Toshiba and BHEL",
|
|
|
19 |
description="Upload a PDF file and select the company to extract and format data into an Excel file according to specific requirements."
|
|
|
20 |
)
|
21 |
|
22 |
if __name__ == "__main__":
|
|
|
23 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
|
3 |
from toshiba import extract_toshiba_data
|
4 |
+
|
5 |
from bhel import extract_bhel_data
|
6 |
|
7 |
def extract_data(pdf_file, company):
|
8 |
+
|
9 |
if company == 'Toshiba':
|
10 |
+
|
11 |
return extract_toshiba_data(pdf_file)
|
12 |
+
|
13 |
elif company == 'BHEL':
|
14 |
+
|
15 |
return extract_bhel_data(pdf_file)
|
16 |
+
|
17 |
else:
|
18 |
+
|
19 |
raise ValueError("Unsupported company format")
|
20 |
|
21 |
company_options = ['Toshiba', 'BHEL']
|
22 |
+
|
23 |
interface = gr.Interface(
|
24 |
+
|
25 |
fn=extract_data,
|
26 |
+
|
27 |
inputs=[gr.File(label="Upload PDF"), gr.Dropdown(choices=company_options, label="Select Company")],
|
28 |
+
|
29 |
outputs=gr.File(label="Download Extracted Data as Excel"),
|
30 |
+
|
31 |
title="PDF Data Extractor for Toshiba and BHEL",
|
32 |
+
|
33 |
description="Upload a PDF file and select the company to extract and format data into an Excel file according to specific requirements."
|
34 |
+
|
35 |
)
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
+
|
39 |
interface.launch()
|