Spaces:
Sleeping
Sleeping
neerajkalyank
commited on
Commit
•
b87add3
1
Parent(s):
ee8c488
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import subprocess
|
|
2 |
import camelot
|
3 |
import pandas as pd
|
4 |
import gradio as gr
|
|
|
|
|
5 |
try:
|
6 |
camelot.__version__
|
7 |
except ImportError:
|
@@ -11,16 +13,15 @@ except ImportError:
|
|
11 |
def extract_tables(pdf_file):
|
12 |
tables = camelot.read_pdf(pdf_file.name, pages="all")
|
13 |
df = pd.concat([table.df for table in tables], ignore_index=True)
|
14 |
-
df
|
15 |
-
return "output.xlsx"
|
16 |
|
17 |
-
|
18 |
fn=extract_tables,
|
19 |
inputs=gr.File(label="Upload PDF"),
|
20 |
-
outputs=gr.
|
21 |
title="PDF Table Extractor",
|
22 |
-
description="Extract tables from PDF
|
23 |
)
|
24 |
|
25 |
if __name__ == "__main__":
|
26 |
-
|
|
|
2 |
import camelot
|
3 |
import pandas as pd
|
4 |
import gradio as gr
|
5 |
+
|
6 |
+
# Install Ghostscript if missing
|
7 |
try:
|
8 |
camelot.__version__
|
9 |
except ImportError:
|
|
|
13 |
def extract_tables(pdf_file):
|
14 |
tables = camelot.read_pdf(pdf_file.name, pages="all")
|
15 |
df = pd.concat([table.df for table in tables], ignore_index=True)
|
16 |
+
return df
|
|
|
17 |
|
18 |
+
demo = gr.Interface(
|
19 |
fn=extract_tables,
|
20 |
inputs=gr.File(label="Upload PDF"),
|
21 |
+
outputs=gr.DataFrame(label="Extracted Tables"),
|
22 |
title="PDF Table Extractor",
|
23 |
+
description="Extract tables from PDF files.",
|
24 |
)
|
25 |
|
26 |
if __name__ == "__main__":
|
27 |
+
demo.launch()
|