Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,12 @@ import pdfplumber
|
|
3 |
import pandas as pd
|
4 |
|
5 |
# Function to process PDF and classify transactions
|
6 |
-
def process_pdf(
|
7 |
-
if
|
8 |
return "No file uploaded."
|
9 |
|
10 |
# Extract text from the uploaded PDF
|
11 |
-
with pdfplumber.open(
|
12 |
text = "\n".join([page.extract_text() for page in pdf.pages if page.extract_text()])
|
13 |
|
14 |
# Extract transactions (Modify based on statement format)
|
@@ -37,6 +37,7 @@ def process_pdf(file):
|
|
37 |
|
38 |
return df # Display the table
|
39 |
|
40 |
-
#
|
41 |
-
app = gr.Interface(fn=process_pdf, inputs=gr.File(type="
|
42 |
app.launch()
|
|
|
|
3 |
import pandas as pd
|
4 |
|
5 |
# Function to process PDF and classify transactions
|
6 |
+
def process_pdf(file_path):
|
7 |
+
if file_path is None:
|
8 |
return "No file uploaded."
|
9 |
|
10 |
# Extract text from the uploaded PDF
|
11 |
+
with pdfplumber.open(file_path) as pdf:
|
12 |
text = "\n".join([page.extract_text() for page in pdf.pages if page.extract_text()])
|
13 |
|
14 |
# Extract transactions (Modify based on statement format)
|
|
|
37 |
|
38 |
return df # Display the table
|
39 |
|
40 |
+
# Fix: Use "filepath" instead of "file"
|
41 |
+
app = gr.Interface(fn=process_pdf, inputs=gr.File(type="filepath"), outputs="dataframe", title="Bank Statement Classifier")
|
42 |
app.launch()
|
43 |
+
|