Tutorial

How to automatically split bank statements by account number or date

By PDFjin Content Team Sep 23, 2026 6 min read
Excel to PDF Illustration

How to Automatically Split Bank Statements by Account Number or Date

Automatically splitting large PDF bank statements by specific criteria like account number or date is crucial for efficient financial reconciliation, auditing, and compliance. This process requires more than basic PDF splitting, which typically operates only by page number. Instead, it involves intelligent text extraction and programmatic logic to identify content-based breakpoints within the document.

The core challenge lies in extracting relevant data accurately and using it to define logical split points. This often requires optical character recognition (OCR) for scanned documents, followed by sophisticated text parsing techniques.

The Technical Approach Extracting and Identifying Split Points

Traditional PDF splitters divide documents by fixed page ranges. For bank statements, you need to identify unique identifiers (like account numbers) or specific date ranges. This requires a multi-step programmatic approach:

  1. Text Extraction: The first step is to extract all text from the PDF. For scanned statements, this necessitates performing OCR to convert image-based text into searchable, extractable text.
  2. Pattern Recognition: Once text is available, you use regular expressions (regex) or advanced text parsing to locate the specific data points (account numbers, dates) on each page.
  3. Logic Definition: Based on the identified patterns, you define the rules for where a new document should begin. For instance, a change in the primary account number signifies a new statement. For dates, you might look for changes in reporting periods (e.g., month-end dates).
  4. Programmatic Splitting: With split points defined, a script or specialized software can then precisely split the PDF document into multiple files.

Splitting by Account Number

To split by account number, the system needs to detect when the primary account number displayed on a page changes. This is common when a single PDF contains statements for multiple accounts.

Step-by-Step Implementation for Account Numbers

  1. Pre-process PDF: If the PDF is scanned or image-based, apply OCR. Tools offering AI PDF extraction are particularly effective here for high accuracy.
  2. Extract Page Text: Iterate through each page of the PDF and extract its text content.
  3. Define Account Number Pattern: Use a regular expression to match typical account number formats (e.g., 10-12 digits, often appearing near "Account Number" or "A/C No."). A common regex might look like `\b\d{10,12}\b`.
  4. Track Account Numbers: Store the first account number found. As you process subsequent pages, compare the detected account number to the one currently being tracked.
  5. Identify Split Points: If a page's account number differs from the previous page's, mark the current page as the start of a new statement.
  6. Execute Split: Use a PDF manipulation library or tool to perform the split at the identified page boundaries.

Example Regex for Account Numbers:

\b(?:\d{3}-\d{3}-\d{4}|\d{10,14})\b (Matches 10-digit number like XXX-XXX-XXXX or 10-14 digits consecutively)

Splitting by Date Range

Splitting by date range typically involves identifying the statement period (e.g., "Statement Date: XX/XX/XXXX - XX/XX/XXXX" or "For the month of [Month Year]"). This is essential for monthly or quarterly reconciliation.

Step-by-Step Implementation for Date Ranges

  1. Pre-process PDF: Perform OCR if the document is not searchable.
  2. Extract Page Text: Extract text from each page.
  3. Define Date Patterns: Create regular expressions to capture common date formats (e.g., `MM/DD/YYYY`, `DD-MMM-YYYY`, `Month YYYY`). Look for keywords like "Statement Date", "Period From/To", "For the Month Of".
  4. Identify Statement Period: For each page, attempt to extract the full statement period (start and end date) or at least the primary statement date.
  5. Compare Periods: Keep track of the current statement period. If a page indicates a new period (e.g., a new month or quarter), mark it as a split point. For multi-page statements, all pages within the same period belong together.
  6. Execute Split: Split the PDF at the detected boundaries.

Example Regex for Dates:

\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{4}\b (Matches "Month YYYY")

\b(\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4})\b (Matches common date formats like MM/DD/YYYY or DD-MM-YY)

Tools and Libraries for Automation

Implementing these solutions often involves programming languages with robust PDF and text processing capabilities. Python is a popular choice due to its extensive library ecosystem.

Tool/Library Purpose/Use Case
Python (PyMuPDF/fitz) High-performance PDF parsing, text extraction, and rendering. Excellent for direct PDF manipulation.
Python (pdfminer.six) Extracts text, images, and other data from PDFs. Good for structured text extraction.
Python (PyPDF2) Basic PDF operations like splitting, merging, rotating pages. Simpler text extraction.
Python (re module) Built-in module for regular expression operations to find patterns in text.
Tesseract OCR Open-source OCR engine. Integrates well with Python for converting scanned PDFs to searchable text.

Practical Considerations

Automating the splitting of bank statements by account or date transforms a tedious manual task into an efficient digital workflow. By leveraging OCR, text extraction, and pattern recognition, you can precisely organize your financial documents.

For quick online PDF splitting and a wide range of other document tasks, consider using PDFjin to streamline your workflow and efficiently manage your digital documents.