pm6six commited on
Commit
70c393b
·
verified ·
1 Parent(s): de0992d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
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(file):
7
- if file is None:
8
  return "No file uploaded."
9
 
10
  # Extract text from the uploaded PDF
11
- with pdfplumber.open(file.name) 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,6 +37,7 @@ def process_pdf(file):
37
 
38
  return df # Display the table
39
 
40
- # Gradio Interface
41
- app = gr.Interface(fn=process_pdf, inputs=gr.File(type="file"), outputs="dataframe", title="Bank Statement Classifier")
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
+