Encrypted, deleted after conversion, never shared

2 September 2026Updated 18 October 20268 min read

Bank Statement Data Extraction: 6 Problems We Fixed

How bank statement data extraction works for digital and scanned PDFs, and 6 real problems we hit in Bayainy's engine and how we fixed them, with simple code.

Extreme close-up of code on a screen

While building Bayainy's extraction engine, almost every bug we fixed taught the same lesson: reading the text is easy, knowing which text belongs to which transaction is the problem.

This post explains how bank statement data extraction works, then walks through 6 real problems we hit and how we fixed them, with simple code.

What is bank statement data extraction?

It turns a PDF statement, made for people to read, into structured rows software can use: one row per transaction with date, description, withdrawal, deposit and balance. A tool that does this is often called a bank statement parser.

Digital vs scanned bank statements

Digital statementScanned statement
How to tellYou can select and copy the textAn image; the text cannot be selected
How it is readFrom the text layer, by codeOCR or AI reading the image
SpeedSecondsSlower
Main riskRows rebuilt wronglyA digit misread from a poor scan

6 extraction problems we hit, and how we fixed them

1. A deposit landed in the withdrawal column

Early on, amounts were assigned by their order in the line, so a deposit could fall into the withdrawal column. Now the engine reads the column positions from the table header and places each amount by where it sits on the page.

2. One transaction printed on two lines

A long description wraps onto a second line, and one transaction became two. The rule now: a line with no date and no amount is a continuation, so it joins the row above.

if not line.date and not line.amount:
    rows[-1].description += " " + line.text   # continuation of the row above
else:
    rows.append(line)
Simplified logic for joining a continuation line to the transaction above.

3. An amount glued to the description

Some statements print the amount stuck to the description with no space, such as PANDA1,250.00, and the amount got lost. The fix reads the amount from the end of the text with a clear number pattern.

import re
m = re.search(r"(\d{1,3}(?:,\d{3})*\.\d{2})$", "POS PANDA1,250.00")
m.group(1)   # '1,250.00'
Pulling an amount glued to the end of a description.

4. A summary page read as transactions

Summary pages have numbers too, so they were treated as transactions, or handed to users instead of the transaction pages. Now a page counts as a transaction page only when it has enough dates, not just numbers.

5. Balances printed on only some rows

Some banks do not print the balance after every transaction. The check now runs between each pair of rows that do show a balance: the transactions in between must add up to the difference.

6. Arabic descriptions lost after cleanup

Our description clean-up step sometimes replaced an Arabic description with an English summary. Now descriptions stay in the bank's language, and masked numbers stay masked.

The check that catches the rest: the running balance

balance = opening
for row in rows:
    balance += row.deposit - row.withdrawal
    assert abs(balance - row.printed_balance) < 0.01   # else: flag the row
Every row is proven against the printed balance. If it does not match, the row is flagged for review.

This check is what makes each of the six problems above show up at once, instead of ending up in your file.

How Bayainy reads a statement today

  • Digital statements: rows are built by code from the page layout and proven by the running balance.
  • Pages that do not pass the check, and scanned pages: read with AI, then proven by the same balance check.
  • Arabic, English and bilingual statements from more than 1,300 banks.

Frequently asked questions

Can you extract data from a scanned bank statement?

Yes. Scanned pages are read with AI, then checked against the balance like digital statements.

Is OCR enough?

OCR reads the characters, but it does not know which number belongs to which transaction. You still need to rebuild the rows and check the balance.

How do I know the extraction is complete?

The opening balance plus every transaction must equal the closing balance on the statement. If they agree, no transaction was lost.

IBM: What is optical character recognition (OCR)?

A technical explanation of how document images become readable text

PDF to Excel Converter

Try the extraction on your own statement, with the balance checked

Bank Statement OCR

How scanned and photographed statements are read

Try Bayainy for Free

Upload your bank statement and get a classified Excel in seconds. 3 pages free, no signup.

Get Started Free

More articles