Registry / finance / bai2
library0.15.0pypypiunverified

BAI2 is a Python library for parsing BAI2 files, a standard format for bank statement reporting. Version 0.15.0 supports Python >=3.6 and provides a simple parser to extract account transactions, balances, and metadata. The project is maintained by the Ministry of Justice (UK). Release cadence is low; last update was 2023.

pip install bai2
INSTALL
IMPORT
SIG · BAI2
B
bai2
financepythonv0.15.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BAI2Parser
from bai2 import BAI2Parser
from bai2 import BAI2Parser

Parse a BAI2 file string and access account and transaction data.

from bai2 import BAI2Parser parser = BAI2Parser() # Replace with actual BAI2 file content bai2_content = "01,MINISTRYOFJUSTICE,230421,123456,USD,001\n02,1234567890,USD,001\n03,1234567890,USD,001,220421,220421\n16,190,4,0001,4000000,,\n22,1,8,1000000,,\n49,10000000,4,,\n98,10000000,1,, 99,10000000,1,," result = parser.parse(bai2_content) print(result.number_of_accounts) print(result.accounts[0].transactions[0].amount)
Debug
Known issues
gotchaThe BAI2Parser.parse() method expects a string, not a file path. You must read the file yourself.
fix
Use open('file.bai2', 'r').read() to pass the content.
affects: all
gotchaThe library does not validate the BAI2 structure strictly. Malformed files may raise exceptions or produce incomplete objects.
fix
Always wrap parsing in try/except and check for None fields.
affects: all
deprecatedThe library's Python requirement is >=3.6, but some internal type hints may not be compatible with Python 3.6 edge cases.
fix
Use Python 3.7 or later if you encounter RuntimeError related to 'from __future__ import annotations'.
affects: 0.15.0
Upgrade
Version history
0.15.0latest on PyPI · released Nov 4, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
40
Resources
bai2 — pip install bai2 · libregistry