If you have ever tried copy-pasting transactions from a Chase, Bank of America, Barclays, or Revolut PDF statement into Excel, you know the pain: columns merge, signs flip, and one missed minus sign ruins your entire monthly close.

Worse, sending financial PDFs to generic LLMs introduces two fatal problems for bookkeeping:

  1. Hallucinated digits — a single misread $1,840.00 vs $1,890.00 breaks reconciliation.
  2. Privacy risk — uploading sensitive client bank statements to third-party AI APIs violates most accounting firms' data policies.

Here is the deterministic coordinate-based Python pipeline we built to solve this cleanly—and verify every statement down to $0.00 variance.

1. Extract Layout-Preserving Rows with pdfplumber

Instead of naive text extraction, preserving horizontal layout keeps dates, descriptions, debits/credits, and running balances aligned:

import io, pdfplumber def extract_statement_lines(pdf_bytes: bytes) -> list[str]: lines = [] with pdfplumber.open(io.BytesIO(pdf_bytes)) as pdf: for page in pdf.pages: text = page.extract_text(layout=True) or "" lines.extend(line.strip() for line in text.splitlines() if line.strip()) return lines 

2. Verify Every Row Against the Running Balance

The secret to 100% bookkeeping accuracy is mathematical proof, not guesswork:

  • Parse the statement's Opening Balance and Closing Balance.
  • For each transaction row that includes a running balance, compute delta = current_balance - previous_balance to deterministically infer whether the row is a debit or credit—even when a bank omits +/- signs.
  • Finally, assert:
expected_closing = round(opening_balance + total_credits - total_debits, 2) variance = round(closing_balance - expected_closing, 2) assert abs(variance) <= 0.02, f"Reconciliation mismatch: {variance}" 

When variance == 0.00, you have mathematical certainty that zero transactions were dropped or misread.

3. Export Directly to Excel (.xlsx), QuickBooks (.qbo) & Xero

Bookkeepers rarely want just a raw CSV. In production, generating a styled multi-sheet Excel workbook (Transactions + Category Summary) alongside a valid OFX/Web Connect .qbo file saves hours every month.

Try It Live (Zero-Login Web Tool & REST API)

We packaged this exact deterministic engine—along with two companion PDF-to-data utilities—into ToolForge:

If you're building bookkeeping automations or RAG pipelines and hit weird bank statement layouts, drop a comment with the bank format and I'll add support for it!