Parse bank statements in Python by reading pdfplumber's words by position, or post the PDF to parserkit at $0.02 a page, 50 pages free, so a 3-page statement costs $0.06 with every balance checked.

Parse bank statements in Python

extract_tables() finds 0 tables on a statement printed in open columns. Reading words by position gets every row, even rows split across 2 pages, and a running-balance check proves none went missing.

GuidesUpdated

Step by step

Parse bank statements in Python

  1. See why extract_tables() returns nothing

    The statement prints DATE, TRANSACTION DETAILS, DEBIT, CREDIT and BALANCE as open columns with no ruling lines, so extract_tables() finds 0 tables on each of the 3 pages. extract_text() does read the words, but look at the top of page 2: after the running header and the column header, Terminal 2 and online orders sits on a line of its own with no amount. It is the second line of a 12 Sep card settlement that starts at the bottom of page 1.

    statement_tables.py
    import pdfplumber
    
    with pdfplumber.open("banksia-statement-2026-09.pdf") as pdf:
        for page in pdf.pages:
            print(f"page {page.page_number}: {len(page.extract_tables())} tables")
        print(pdf.pages[1].extract_text().splitlines()[:4])
    
    # $ python statement_tables.py
    # page 1: 0 tables
    # page 2: 0 tables
    # page 3: 0 tables
    # ['Banksia Ridge Bank, statement continued 01 Sep 2026 to 30 Sep 2026', 'DATE TRANSACTION DETAILS DEBIT CREDIT BALANCE', 'Terminal 2 and online orders', 'Card purchase, Northside Office Supplies 46.90 3,870.55 CR']
  2. Read words by position

    parse() works from extract_words(). It finds the header row by the word DEBIT, groups words into lines by their top position with cluster_objects and a tolerance of 3 points, and puts each amount in the DEBIT, CREDIT or BALANCE column whose header ends closest to the amount's right edge. A line with a balance starts a new row. A line without one joins the row before it, across a page break too, and a blank date takes the last date printed. Parsing stops at CLOSING BALANCE, so the footer stays out.

    parse_statement.py
    import json
    import re
    import sys
    from decimal import Decimal
    
    import pdfplumber
    from pdfplumber.utils import cluster_objects
    
    MONEY = re.compile(r"^-?\(?[\d,]+\.\d{2}\)?-?$")
    
    
    def amount(text):
        text = text.replace(",", "").strip()
        negative = text.endswith(("DR", "-")) or text.startswith(("-", "("))
        number = Decimal(text.removesuffix("CR").removesuffix("DR").strip(" ()-"))
        return -number if negative else number
    
    
    def table_lines(page):
        words = page.extract_words()
        debit = next(w for w in words if w["text"] == "DEBIT")
        head = {w["text"]: w for w in words if abs(w["top"] - debit["top"]) < 2}
        footer = max(w["top"] for w in words if w["text"] == "Page")
        body = [w for w in words if head["DEBIT"]["bottom"] < w["top"] < footer]
        columns = {name: head[name]["x1"] for name in ("DEBIT", "CREDIT", "BALANCE")}
    
        for line in cluster_objects(body, "top", 3):
            line.sort(key=lambda w: w["x0"])
            date = " ".join(w["text"] for w in line if w["x1"] < head["TRANSACTION"]["x0"])
            text = " ".join(w["text"] for w in line if w["x0"] >= head["TRANSACTION"]["x0"] and not MONEY.match(w["text"]) and w["text"] not in ("CR", "DR"))
            money = {}
            for w in line:
                if MONEY.match(w["text"]):
                    column = min(columns, key=lambda name: abs(columns[name] - w["x1"]))
                    money[column] = w["text"]
                elif w["text"] in ("CR", "DR") and "BALANCE" in money:
                    money["BALANCE"] += " " + w["text"]
            yield date, text, money
    
    
    def parse(path):
        rows, opening, closing, day = [], None, None, None
        with pdfplumber.open(path) as pdf:
            for page in pdf.pages:
                for date, text, money in table_lines(page):
                    if closing is not None:
                        break
                    day = date or day
                    if text == "OPENING BALANCE":
                        opening = amount(money["BALANCE"])
                    elif text == "CLOSING BALANCE":
                        closing = amount(money["BALANCE"])
                    elif "BALANCE" in money:
                        rows.append({
                            "date": day,
                            "description": text,
                            "debit": amount(money.get("DEBIT", "0")),
                            "credit": amount(money.get("CREDIT", "0")),
                            "balance": amount(money["BALANCE"]),
                        })
                    elif text and rows:
                        rows[-1]["description"] += " / " + text
        return opening, rows, closing
    
    
    if __name__ == "__main__":
        opening, rows, closing = parse(sys.argv[1])
        print(f"{len(rows)} rows, opening {opening}, closing {closing}")
        for row in (rows[21], rows[53]):
            print(json.dumps(row, default=str))
    
    # $ python parse_statement.py banksia-statement-2026-09.pdf
    # 59 rows, opening 1842.35, closing 10112.19
    # {"date": "12 Sep", "description": "Card settlement, Corella Street counter / Terminal 2 and online orders", "debit": "0", "credit": "1312.70", "balance": "3917.45"}
    # {"date": "28 Sep", "description": "BPAY, Queensland Revenue Office / Payroll tax 2026-08", "debit": "486.00", "credit": "0", "balance": "9570.90"}
  3. Turn DR, CR and minus signs into numbers

    Banks print signs in many ways. This statement marks balances with CR and DR, its footer says DR means the account is overdrawn, and on 4 Sep the balance reads 535.05 DR. amount() turns that into -535.05 and 1,204.00 CR into 1204.00, and reads -86.40, (86.40) and 86.40- as -86.40. It returns Decimal, not float, so sums stay exact to the cent.

    amounts.py
    from parse_statement import amount
    
    for printed in ["535.05 DR", "1,204.00 CR", "-86.40", "(86.40)", "86.40-"]:
        print(f"{printed:>12} -> {amount(printed)}")
    
    # $ python amounts.py
    #    535.05 DR -> -535.05
    #  1,204.00 CR -> 1204.00
    #       -86.40 -> -86.40
    #      (86.40) -> -86.40
    #       86.40- -> -86.40
  4. Prove it with the running balance

    check() starts from the opening balance, adds each credit, subtracts each debit and compares the result with the balance printed on that row, then with the closing balance. On the full parse every balance matches. To see it catch a gap, the script deletes 1 row and runs again: the next row fails, 17 Sep Transfer to Paddington Packaging, expected 3381.20 against 3196.60 printed. A dropped or misread row can't hide from this check.

    check_balances.py
    from parse_statement import parse
    
    
    def check(opening, rows, closing):
        problems = []
        balance = opening
        for row in rows:
            balance += row["credit"] - row["debit"]
            if balance != row["balance"]:
                problems.append(f"{row['date']} {row['description']}: expected {balance}, printed {row['balance']}")
                balance = row["balance"]
        if balance != closing:
            problems.append(f"closing balance: expected {balance}, printed {closing}")
        return problems
    
    
    opening, rows, closing = parse("banksia-statement-2026-09.pdf")
    print(check(opening, rows, closing) or "OK: every running balance and the closing balance add up")
    
    del rows[30]
    for problem in check(opening, rows, closing):
        print(problem)
    
    # $ python check_balances.py
    # OK: every running balance and the closing balance add up
    # 17 Sep Transfer to Paddington Packaging / Ref PP-77188: expected 3381.20, printed 3196.60
  5. Send the same PDF to the API

    Skip the position rules: post the statement to parserkit with the bank_statement preset. The example below is our run of this statement. It came back partial, with all but 2 values checked, and all 5 checks passed: the closing balance worked out 2 ways, both totals, and every printed balance following from the one before. Both rows that cross a page break come back whole, with Terminal 2 and online orders and Payroll tax 2026-08 joined to their descriptions, but those 2 descriptions stay unchecked. The rows print no year (01 Sep), so the year comes from the statement period, 01 Sep 2026 to 30 Sep 2026, and each of the 30 printed dates is checked on its own row. The 29 rows with a blank date take the date above, the same way parse() does, and are marked inherited_from instead of counted, since nothing is printed there. The 3-page run cost $0.06; volume rates are on pricing.

Example

banksia-statement-2026-09.pdf through the bank_statement preset

Our run of the 3-page statement: the request, and the response as it came back.

POSTapi.parserkit.com/v1/parse?wait=60

curl "https://api.parserkit.com/v1/parse?wait=60" \
  -H "Authorization: Bearer $PARSERKIT_API_KEY" \
  -F file=@banksia-statement-2026-09.pdf \
  -F preset=bank_statement
response.jsonpartial

2 of 219 values went unchecked: the 2 descriptions that cross a page break, which come back joined but unchecked. The 29 dates the statement leaves blank take the date above and are not counted.

{
  "id": "job_y8hplufa4otghoahzr8y",
  "status": "succeeded",
  "preset": "bank_statement",
  "pages": 3,
  "cost_usd": 0.06,
  "verification_status": "partial",
  "data": {
    "bank": {
      "name": "Banksia Ridge Bank",
      "address": "120 Ann Street, Brisbane QLD 4000"
    },
    "account": {
      "holder": "Corella Street Bakery Pty Ltd",
      "number": "1029 4471",
      "routing_number": "484-199",
      "type": "Business transaction account statement"
    },
    "currency": "AUD",
    "period_start": "2026-09-01",
    "period_end": "2026-09-30",
    "opening_balance": 1842.35,
    "closing_balance": 10112.19,
    "total_credits": 26612.24,
    "total_debits": 18342.4,
    "transactions": [
      {
        "date": "2026-09-01",
        "description": "Card settlement, Corella Street counter",
        "amount": 1186.4,
        "balance": 3028.75,
        "page": 1
      },
      {
        "date": "2026-09-12",
        "description": "Card settlement, Corella Street counter Terminal 2 and online orders",
        "amount": 1312.7,
        "balance": 3917.45,
        "page": 1
      },
      {
        "date": "2026-09-28",
        "description": "BPAY, Queensland Revenue Office Payroll tax 2026-08",
        "amount": -486,
        "balance": 9570.9,
        "page": 2
      }
    ]
  },
  "verification": {
    "status": "partial",
    "math_balanced": true,
    "coverage": {
      "values": 219,
      "checked": 217
    },
    "checks": [
      {
        "kind": "balance",
        "path": "closing_balance",
        "status": "pass",
        "expected": 10112.19,
        "actual": 10112.19,
        "difference": 0,
        "message": "opening balance + total credits - total debits"
      },
      {
        "kind": "sum",
        "path": "total_credits",
        "status": "pass",
        "expected": 26612.24,
        "actual": 26612.24,
        "difference": 0,
        "message": "sum of the money-in rows"
      },
      {
        "kind": "sum",
        "path": "total_debits",
        "status": "pass",
        "expected": 18342.4,
        "actual": 18342.4,
        "difference": 0,
        "message": "sum of the money-out rows"
      },
      {
        "kind": "balance",
        "path": "closing_balance",
        "status": "pass",
        "expected": 10112.19,
        "actual": 10112.19,
        "difference": 0,
        "message": "opening balance + every transaction"
      },
      {
        "kind": "running_balance",
        "path": "transactions[].balance",
        "status": "pass",
        "message": "59 of 59 printed balances follow from the one before (in printed order)"
      }
    ]
  },
  "outputs": [
    {
      "name": "output.json",
      "bytes": 83705
    },
    {
      "name": "output.xlsx",
      "bytes": 11672
    },
    {
      "name": "output.csv",
      "bytes": 4202
    },
    {
      "name": "quickbooks.csv",
      "bytes": 3595
    },
    {
      "name": "xero.csv",
      "bytes": 6083
    }
  ],
  "warnings": []
}

Real response from . Trimmed to 3 of 59 transactions, the first one and the 2 that cross a page break, with bounding boxes, empty fields and file links left out, and without the duplicate flag from our earlier runs of this file.

Where this statement breaks a parser, and the fix

banksia-statement-2026-09.pdf: 3 pages, 59 transactions, in Australian dollars.

Where this statement breaks a parser, and the fix
ProblemOn this statementFix in parse_statement.py
No ruling linesextract_tables() finds 0 tables on all 3 pagesGroup extract_words() into lines by top position
Row runs onto the next pageTerminal 2 and online orders opens page 2A line with no balance joins the row before it
Date printed once a dayOnly the first row of a day shows the dateCarry the last date down
Overdrawn balance535.05 DR on 4 Sepamount() makes DR negative
Text under the tableDR means the account is overdrawn.Stop at CLOSING BALANCE
A row goes missing1 row deleted on purposeThe running balance fails on the next row

Where the script breaks on the next statement

parse_statement.py fits this one bank. MONEY only matches amounts with a point and 2 decimals, so a European amount like 1.234,56 is read as text and its row folds into the one above. table_lines() looks for the exact words DEBIT, CREDIT, BALANCE and TRANSACTION and for a footer that says Page, so a bank that prints Withdrawals and Deposits stops the script with an exception. A scanned statement has no text layer, so extract_words() returns nothing, and pdfplumber says itself that it works best on machine-generated PDFs. check() adds credits and subtracts debits in printed order, so a statement printed newest first, or a card account where spending grows the balance, fails row after row even when no row is missing.

parserkit's bank_statement preset reads amounts printed as (7.02), 7,02-, with DR or CR, as 1.234,56 or as 1'234.56, reads scanned pages with OCR, and checks the rows in printed order or newest first, as a bank or a card account, keeping the reading that reconciles. One call, and the QuickBooks and Xero files come with it.

What we ran

Every script here ran on Python 3.12.14. The lines under # $ in each code block are what the script printed, cut only where you see ....

Banksia Ridge Bank and Corella Street Bakery are made up: we built the statement for this guide so it has the problems real statements have, in one file. The script that drew it and every output are linked under Sources.

versions.py
import platform
import subprocess
import sys
from importlib.metadata import version

TOOLS = {
    "tesseract": lambda: subprocess.run(["tesseract", "--version"], capture_output=True, text=True).stdout.split()[1],
    "ollama": lambda: subprocess.run(["ollama", "--version"], capture_output=True, text=True).stdout.split()[-1],
    "libreoffice": lambda: subprocess.run(["soffice", "--version"], capture_output=True, text=True).stdout.split()[1],
}

print("Python", platform.python_version())
for name in sys.argv[1:]:
    print(name, TOOLS[name]() if name in TOOLS else version(name))

# $ python versions.py pdfplumber
# Python 3.12.14
# pdfplumber 0.11.10

FAQ

Common questions

Why does pdfplumber find no table on my bank statement?

extract_tables() looks for ruling lines by default. Many statements print their columns as open space with no lines, so it returns 0 tables. Read the words with extract_words() and give each amount a column by its position instead. parserkit's bank_statement preset reads statements like this one with no ruling lines, and scans too.

How do I handle DR and CR amounts?

Strip the mark and set the sign before you convert to Decimal. On this statement CR is a positive balance and DR an overdrawn one, so 535.05 DR becomes -535.05 and 1,204.00 CR becomes 1204.00. Read -86.40, (86.40) and 86.40- as -86.40 too. Check your bank's footer for what its marks mean. parserkit's bank_statement preset reads DR and CR, parentheses, trailing minus signs and comma decimals like 1.234,56 as signed amounts already.

How do I know no row went missing?

Run a running-balance check from the opening balance to the closing balance: add each credit, subtract each debit and compare with the balance printed on each row. If a row is dropped or an amount lands in the wrong column, the next row fails. parserkit runs that check on every statement, newest-first and card statements included, and names the row that fails with both numbers.

What does it cost to parse a statement with the API?

$0.02 a page, and $0.01 a page past 5,000 pages in a month. A 3-page statement costs $0.06. Signing in with Google gives you $1.00 of credit, which is 50 pages free. Failed jobs cost nothing.

Start free

Send us your worst scan

Your first $1 is free: 50 pages with every check and export, no card.

Crumpled receipts and a printed bank statement with one line marked in green highlighter, on a dark desk