Data Automation & Cleaning Intermediate

Extract Transaction Tables from PDF Bank Statements to Clean CSV in Python

Use Python and pdfplumber to parse multi-page PDF bank and credit card statements into a clean, standardized Pandas DataFrame and CSV file.

#pdfplumber#pandas

Problem Statement

Manually copying rows from multi-page PDF bank statements into Excel breaks alignment. This in-memory script extracts tabular transaction rows across all pages and exports a clean CSV.

Formula / Core Logic

Iterates through each PDF page using bounding-box table detection (page.extract_tables()) and strips currency noise via regex.

Installation

pip install pdfplumber pandas
extract-tables-from-pdf-bank-statement-python.py
import pdfplumber
import pandas as pd

def parse_bank_pdf(pdf_path, out_csv='statement.csv'):
    rows = []
    with pdfplumber.open(pdf_path) as pdf:
        for page in pdf.pages:
            for table in page.extract_tables():
                rows.extend(table)
    df = pd.DataFrame(rows[1:], columns=rows[0])
    df.to_csv(out_csv, index=False)
    return df

Get the Complete 100+ Python Quant & Automation Bundle

Instant lifetime access to all production-ready scripts, valuation models, and trading bots ($19).

Buy Full Bundle on Gumroad ($19) →

Frequently Asked Questions

Q: Does this work on scanned PDFs?

pdfplumber works on digital PDFs. For scanned images, use pytesseract OCR.