Skip to main content

A package for extracting JSON data from Maybank PDF account statements

Project description

maybankpdf2json

PyPI version Python versions CI License Last Commit

A small Python library to extract transaction data from Maybank PDF account statements.

Install

Requires Python 3.8 or newer.

pip install maybankpdf2json

Quick Start

from maybankpdf2json import MaybankPdf2Json

with open("statement.pdf", "rb") as f:
    extractor = MaybankPdf2Json(f, "your_pdf_password")

    # Raw Python data
    transactions = extractor.data()
    print(transactions[0])

    # Nicely formatted JSON string
    print(extractor.dumps())

    # Full output with account metadata
    print(extractor.dumps_v2())

API

MaybankPdf2Json(buffer, pwd)

  • json() -> List[Output]
    • Returns transaction rows with fields: date, desc, trans, bal.
  • data() -> List[Output]
    • Clearer alias for json().
  • jsonV2() -> dict
    • Returns:
      • account_number: statement account number when available
      • statement_date: statement date in dd/mm/yy
      • transactions: same list as json()
  • data_v2() -> dict
    • Clearer alias for jsonV2().
  • dumps(indent=2) -> str
    • Returns transaction data as nicely formatted JSON text.
  • dumps_v2(indent=2) -> str
    • Returns account metadata plus transactions as nicely formatted JSON text.

Output Notes

  • Dates use dd/mm/yy.
  • Amounts support trailing sign notation from statements:
    • 123.45- -> -123.45
    • 123.45+ -> 123.45

Example pretty-printed output:

Transaction list output from dumps():

[
  {
    "date": "01/09/24",
    "desc": "BEGINNING BALANCE",
    "trans": 0,
    "bal": 3285.77
  },
  {
    "date": "01/09/24",
    "desc": "TRANSFER FROM A/C MBBQR1714285 * 11111755387009 124998670Q",
    "trans": -10.0,
    "bal": 3275.77
  }
]

Full output from dumps_v2():

{
  "account_number": "162021-851156",
  "statement_date": "30/09/24",
  "transactions": [
    {
      "date": "01/09/24",
      "desc": "BEGINNING BALANCE",
      "trans": 0,
      "bal": 3285.77
    }
  ]
}

Development

Install project dependencies:

make install

Run tests:

make test

Alternative test command:

pytest tests/

See CONTRIBUTING.md for development workflow and docs/ARCHITECTURE.md for parser internals.

Release

See CHANGELOG.md for release history.

Automatic PyPI publishing is configured with GitHub Actions in .github/workflows/publish.yml.

One-time setup on PyPI:

  1. Open the project on PyPI.
  2. Add a Trusted Publisher for this GitHub repository.
  3. Use workflow name publish.yml.
  4. Use environment name pypi.

Release flow:

  1. Move items from [Unreleased] in CHANGELOG.md into a new version section.
  2. Update the version in pyproject.toml and setup.py.
  3. Commit and push main.
  4. Create and push a version tag such as v0.1.53.
  5. GitHub Actions builds the package and publishes it to PyPI automatically.

Example:

git tag v0.1.53
git push origin v0.1.53

Local manual release remains available for maintainers:

make release

This builds and uploads to PyPI using Twine. Run only with valid release credentials.

License

MIT. See 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

maybankpdf2json-0.1.53.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

maybankpdf2json-0.1.53-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file maybankpdf2json-0.1.53.tar.gz.

File metadata

  • Download URL: maybankpdf2json-0.1.53.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for maybankpdf2json-0.1.53.tar.gz
Algorithm Hash digest
SHA256 0964daf11a25087927ea7a81d12e2d4c5fb6ce05ab01f36c4541ccf70c717f7f
MD5 207113749783a163b8f13d80bca7415b
BLAKE2b-256 c44884ccdbb3468aa1c453d8c7b0cd4a100c2d601e17b0f3e63cceba740c8295

See more details on using hashes here.

Provenance

The following attestation bundles were made for maybankpdf2json-0.1.53.tar.gz:

Publisher: publish.yml on nordinz7/maybankpdf2json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maybankpdf2json-0.1.53-py3-none-any.whl.

File metadata

File hashes

Hashes for maybankpdf2json-0.1.53-py3-none-any.whl
Algorithm Hash digest
SHA256 0ee88d625f71d41ad7ebe80a7c424b553cac84e392653072b5eca0cb912a623b
MD5 469aaf535f21dac29e21d7062c25bf82
BLAKE2b-256 33f3df841a961df258571be242659b12e3f2fae71345ddbec60bd9e865466f93

See more details on using hashes here.

Provenance

The following attestation bundles were made for maybankpdf2json-0.1.53-py3-none-any.whl:

Publisher: publish.yml on nordinz7/maybankpdf2json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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