Skip to main content

Parse credit card PDF statements into structured financial data. Currently supports TD Business Solutions Visa.

Project description

ccparse

A Python library for extracting high-fidelity financial data from TD Business Solutions Visa "born-digital" PDF statements.

Parses transactions, balance summaries, and rewards points into structured domain objects, validates the Golden Equation on every parse, and exports to Pandas DataFrames.


Features

  • Extracts all transactions with activity date, post date, reference number, description, and amount
  • Correctly handles CR (credit balance) signage — stored as negative Decimal values
  • Validates Previous Balance + Purchases - Credits + Fees + Interest = New Balance on every parse; raises BalanceMismatchError if it fails
  • All monetary values use decimal.Decimal — floating-point arithmetic is never used
  • Exports to a Pandas DataFrame with datetime64 date columns
  • All processing is local — no network calls, no data storage

Installation

pip install ccparse

Requires Python 3.11+.


Quick Start

from ccparse import TDStatementParser

parser = TDStatementParser()
statement = parser.parse("path/to/statement.pdf")

# Metadata
print(statement.account_suffix)          # "5679"
print(statement.billing_period_start)    # datetime.date(2024, 7, 4)
print(statement.billing_period_end)      # datetime.date(2024, 8, 3)

# Balance summary
print(statement.balance_summary.new_balance)       # Decimal('-1151.02')
print(statement.balance_summary.previous_balance)  # Decimal('-1516.49')
print(statement.balance_summary.purchases)         # Decimal('365.47')

# Transactions
for t in statement.transactions:
    print(t.activity_date, t.reference_number, t.description, t.amount)

# Rewards
print(statement.current_points)  # 6050

Pandas Export

from ccparse import TDStatementParser
from ccparse.export import to_df

statement = TDStatementParser().parse("path/to/statement.pdf")
df = to_df(statement)

print(df.dtypes)
# activity_date    datetime64[ns]
# post_date        datetime64[ns]
# reference_number         object
# description              object
# amount                  float64

Error Handling

from ccparse import TDStatementParser, BalanceMismatchError, DataIntegrityError

try:
    statement = TDStatementParser().parse("path/to/statement.pdf")
except BalanceMismatchError as e:
    # Golden Equation failed — the PDF figures don't add up
    print(e)
except DataIntegrityError as e:
    # A required field could not be extracted
    print(e)
Exception Raised when
BalanceMismatchError Golden Equation validation fails
DataIntegrityError A required field is missing or unparseable
TDParserError Base class for all library errors

Data Model

@dataclass
class Statement:
    entity_name: str
    primary_cardholder: str
    account_suffix: str
    billing_period_start: date
    billing_period_end: date
    balance_summary: BalanceSummary
    current_points: int
    transactions: List[Transaction]

@dataclass(frozen=True)
class Transaction:
    activity_date: date
    post_date: date
    reference_number: str   # maps to <FITID> in OFX/QBO
    description: str
    amount: Decimal         # positive = spend, negative = payment/credit

@dataclass(frozen=True)
class BalanceSummary:
    previous_balance: Decimal
    purchases: Decimal
    credits: Decimal
    fees: Decimal
    interest: Decimal
    new_balance: Decimal
    available_credit: Decimal
    minimum_payment: Decimal

Development

git clone https://github.com/rmuktader/ccparse
cd ccparse
uv sync
uv run pytest tests/ -v

Roadmap

Version Features
0.1 (MVP) TD Business Visa parsing, Pandas export, balance validation
1.1 OFX / QBO / CSV export, rewards validation, optional dependency extras
2.0 Multi-bank strategy (Chase, Amex)

License

MIT

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

ccparse-0.1.1.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

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

ccparse-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file ccparse-0.1.1.tar.gz.

File metadata

  • Download URL: ccparse-0.1.1.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for ccparse-0.1.1.tar.gz
Algorithm Hash digest
SHA256 31a7e22b8679991519ff8219107ce534589135b4a895b6d8da6d90020fe9afd0
MD5 0dc9dfde91bb0d01798d63e7f07188a0
BLAKE2b-256 ccbaa3bc8c307ef25933012eb8a6bffd5b7d014558cf4636e9cb1ff9eedda760

See more details on using hashes here.

File details

Details for the file ccparse-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ccparse-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for ccparse-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef4c801a2c4b97ff4d68332fb58fd517a12ab0d2ba350dc67a688a7ea991bdc1
MD5 917f1a2d4a587bf69370eef76f6d3760
BLAKE2b-256 c75d8af27ffe34ec3940b80aec1c81ae17a19370c0e76753c95e6c34c3969514

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