Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,8 @@ import pdfplumber
|
|
| 2 |
import re
|
| 3 |
import PyPDF2
|
| 4 |
import pandas as pd
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Function to extract tables from PDF using pdfplumber
|
| 7 |
def extract_table_from_pdf(pdf_path):
|
|
@@ -55,17 +57,21 @@ def process_po(pdf_path):
|
|
| 55 |
|
| 56 |
return df
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
def
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
if __name__ == "__main__":
|
| 69 |
-
|
| 70 |
-
pdf_path = 'sample_po.pdf' # Replace with your PDF file path
|
| 71 |
-
main(pdf_path)
|
|
|
|
| 2 |
import re
|
| 3 |
import PyPDF2
|
| 4 |
import pandas as pd
|
| 5 |
+
import re
|
| 6 |
+
import gradio as gr
|
| 7 |
|
| 8 |
# Function to extract tables from PDF using pdfplumber
|
| 9 |
def extract_table_from_pdf(pdf_path):
|
|
|
|
| 57 |
|
| 58 |
return df
|
| 59 |
|
| 60 |
+
# Gradio Interface
|
| 61 |
+
def gradio_interface(pdf_file):
|
| 62 |
+
"""
|
| 63 |
+
Interface function for Gradio to process the PDF and return the Excel file.
|
| 64 |
+
"""
|
| 65 |
+
return extract_data(pdf_file.name)
|
| 66 |
+
|
| 67 |
+
# Define Gradio interface
|
| 68 |
+
interface = gr.Interface(
|
| 69 |
+
fn=gradio_interface,
|
| 70 |
+
inputs=gr.File(label="Upload PDF"),
|
| 71 |
+
outputs=gr.File(label="Download Accurate Excel"),
|
| 72 |
+
title="Accurate BHEL PO Data Extractor",
|
| 73 |
+
description="Upload a PDF to extract accurate Material Numbers and related data into an Excel file."
|
| 74 |
+
)
|
| 75 |
|
| 76 |
if __name__ == "__main__":
|
| 77 |
+
interface.launch()
|
|
|
|
|
|