Untitled
Anonymous
plain_text
02/21/2026 8:56 AM
4.2 KB
11
Indexable
import pdfplumber
import pandas as pd
import re
total_credit = 0
total_debit = 0
with pdfplumber.open("statement.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
if text:
lines = text.split("\n")
for line in lines:
# Find numbers followed by (Cr) or (Dr)
match = re.findall(r'([\d,]+\.\d+)\((Cr|Dr)\)', line)
for amount, txn_type in match:
amount = float(amount.replace(",", ""))
if txn_type == "Cr":
total_credit += amount
else:
total_debit += amount
print("Total Credit:", total_credit)
print("Total Debit:", total_debit)
print("Total Transaction Volume:", total_credit + total_debit)Editor is loading...
Leave a Comment