Skip to main content

Parse financial statements (bank, credit card, UPI) to normalized Excel/CSV format

Project description

Statement Parser

A standalone library for parsing financial statements (bank, credit card, UPI) and converting them to normalized Excel/CSV formats.

Features

  • Pattern-based parsing - Uses regex patterns, not AI (AI can be added as fallback)
  • Multiple statement types - Supports bank statements, credit cards, and UPI payments
  • Adaptive learning - Learns patterns from statements for better parsing
  • Normalized output - Standardizes dates, amounts, and descriptions
  • Multiple export formats - Excel (XLSX), CSV, and JSON

Installation

pip install statement-parser

Or from source:

git clone https://github.com/your-org/statement-parser.git
cd statement-parser
pip install -e .

Usage

Basic Usage

from statement_parser import StatementParser

parser = StatementParser()

# Parse a PDF file
result = parser.parse_file("statement.pdf")

# Access transactions
for tx in result.transactions:
    print(f"{tx['date']}: {tx['description']} - ₹{tx['amount']}")

# Export to Excel
result.to_excel("output.xlsx")

# Get summary
summary = result.get_summary()
print(f"Total transactions: {summary['total_transactions']}")
print(f"Total credits: ₹{summary['total_credits']}")
print(f"Total debits: ₹{summary['total_debits']}")

Command Line Interface

# Parse a single file (outputs Excel by default)
python -m statement_parser examples statement.pdf

# Parse multiple files
python -m statement_parser examples *.pdf

# Output to CSV instead of Excel
python -m statement_parser examples -f csv statement.pdf

# Specify output directory
python -m statement_parser examples -o ./output *.pdf

# Show help
python -m statement_parser --help

Programmatic Usage

from statement_parser import StatementParser, ParseOptions

# Customize options
options = ParseOptions(
    output_format='csv',
    output_dir='./output',
    normalize=True,
    deduplicate=True
)

parser = StatementParser(options)
result = parser.parse_file("statement.pdf")

Supported Statement Types

Bank Statements

  • HDFC Bank (fixed-width and CSV formats)
  • ICICI Bank
  • SBI
  • Other banks with standard formats

Credit Card Statements

  • HDFC Credit Card
  • ICICI Credit Card (including Amazon ICICI)
  • SBI Credit Card
  • AU Bank Credit Card
  • Other credit cards

UPI/Third-party Statements

  • Ixigo
  • AU Bank (via UPI)
  • PhonePe
  • Google Pay
  • Other UPI-based platforms

Output Schema

Bank Statements

Column Description
Date Transaction date (DD/MM/YYYY)
Narration Transaction description
Value Date Value date
Debit Debit amount
Credit Credit amount
Balance Running balance
Reference Reference number

Credit Card Statements

Column Description
Date Transaction date
Merchant Merchant name
Amount Transaction amount
Type Debit/Credit
Card No Card number
Reference Reference number

UPI Statements

Column Description
Date Transaction date
Merchant Merchant/Payee name
Amount Transaction amount
Type Debit/Credit
Reference Reference number
UPI Ref UPI transaction ID

Directory Structure

statement-parser/
├── statement_parser/
│   ├── __init__.py          # Package initialization
│   ├── parser.py            # Main entry point
│   ├── detector.py          # Statement type detection
│   ├── formats/
│   │   ├── __init__.py
│   │   ├── base.py          # Base parser class
│   │   ├── generic_parser.py  # Generic parser (no AI)
│   │   ├── bank_statement.py  # Bank statements
│   │   ├── credit_card.py     # Credit card statements
│   │   └── upi_statement.py   # UPI statements
│   ├── patterns/
│   │   ├── generic.py       # Generic patterns
│   │   ├── hdfc.py          # HDFC patterns
│   │   ├── icici.py         # ICICI patterns
│   │   └── sbi.py           # SBI patterns
│   └── utils/
│       ├── formatting.py    # Number/date normalization
│       └── validation.py    # Output validation
├── tests/
│   ├── test_parser.py
│   └── test_statements/
├── examples/
│   └── cli.py               # CLI tool
├── docs/
│   ├── README.md            # Jupyter examples overview
│   ├── API.md               # API documentation
│   ├── USAGE.md             # Usage examples
│   └── examples/            # Jupyter notebooks
├── pyproject.toml
└── README.md

Development

# Run tests
pytest tests/

# Run tests with coverage
pytest --cov=statement_parser tests/

# Run linter
ruff check .

Documentation

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

expense_statement_parser-0.1.0.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

expense_statement_parser-0.1.0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file expense_statement_parser-0.1.0.tar.gz.

File metadata

  • Download URL: expense_statement_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for expense_statement_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 464745ad1ec0dbc36a3def79871138234fc2ee5792ea1f04b6f002fbb2445c24
MD5 508b85ba8464e96f95e5d7481398c8c8
BLAKE2b-256 2f2f62e1ffe7e5b78f2a91e38cd634fd97b6d34e58560713b5cef6f526d8ea52

See more details on using hashes here.

File details

Details for the file expense_statement_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for expense_statement_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c7815ab609e40421386ae38e3b274951a6e28d1f0f5c59a7f197d301fc7ba44
MD5 1993ca712d9ae46233ee7e281497eeaf
BLAKE2b-256 df5f86f2eb98861cb56f945ef6d99941c3239a23f8ece44e596e52699f7a6efc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page