Skip to main content

BAI2 to CSV Converter

A Python library for converting Bank Administration Institute (BAI2) files to CSV format. This library provides a simple way to parse BAI2 files and convert them into two CSV files: one for transaction summaries and another for transaction details.

Installation

You can install the package using pip:

pip install bai2-to-csv

Usage

Here's a simple example of how to use the library:

from bai2_to_csv import Bai2Converter

# Create a converter instance
converter = Bai2Converter()

# Convert a BAI2 file to CSV
converter.convert_file(
    input_path="path/to/your/input.bai2",
    summary_output_path="path/to/summary.csv",
    detail_output_path="path/to/detail.csv"
)

The converter will create two CSV files:

  1. A transaction summary file containing aggregated transaction information
  2. A transaction detail file containing individual transaction records

Output Format

Transaction Summary CSV

The summary CSV file includes the following columns:

  • customer_account: Account identifier
  • currency_code: Currency of the transactions
  • transaction_bai_code: BAI transaction type code
  • amount: Transaction amount
  • transaction_code: Transaction code
  • transaction_type: Type of transaction
  • fund_available_immediately: Funds available now
  • fund_available_in_one_day: Funds available next day
  • fund_available_in_two_days: Funds available in two days

Transaction Detail CSV

The detail CSV file includes:

  • customer_account: Account identifier
  • currency_code: Currency of the transactions
  • transaction_bai_code: BAI transaction type code
  • amount: Transaction amount
  • fund_type: Type of funds
  • bank_reference: Bank reference number
  • customer_reference: Customer reference number
  • transaction_text: Detailed transaction description

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/yourusername/bai2-to-csv.git
cd bai2-to-csv

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Running Tests

The project includes comprehensive unit tests, integration tests, and linting checks.

Quick Test Run

# Run all tests with coverage
python -m pytest tests/ -v --cov=src/bai2_to_csv --cov-report=term-missing

# Run only unit tests
python -m pytest tests/test_*.py -v

# Run only integration tests
python -m pytest tests/test_integration.py -v

Full CI Test Suite

# Run the complete test suite (same as CI)
./scripts/run_tests.sh

This will run:

  • Code formatting checks (black)
  • Import sorting checks (isort)
  • Linting (flake8)
  • Type checking (mypy)
  • Unit tests with coverage reporting

Test Coverage

After running tests with coverage, you can view:

  • Terminal coverage report
  • HTML coverage report: htmlcov/index.html
  • XML coverage report: coverage.xml

GitHub Actions CI

The project uses GitHub Actions for continuous integration. On every push and pull request, the CI will:

  1. Test Matrix: Run tests on Python 3.9, 3.10, 3.11, and 3.12
  2. Quality Checks: Format, imports, linting, and type checking
  3. Unit Tests: Complete test suite with coverage reporting
  4. Integration Tests: End-to-end workflow testing
  5. Coverage Reporting: Upload coverage to Codecov
  6. Artifacts: Store test results and coverage reports

The CI configuration is in .github/workflows/ci.yml.

Metadata

Release files for bai2-to-csv 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bai2-to-csv 0.1.0
File Size Uploaded Provenance
bai2_to_csv-0.1.0.tar.gz 8.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bai2-to-csv 0.1.0
File Interpreter ABI Platform
bai2_to_csv-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / bai2_to_csv-0.1.0.tar.gz

Download URL bai2_to_csv-0.1.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c381e5a140de022cbde76d61c3378cbca929ea0bda04946693293080febd0997
BLAKE2b-256 checksum
How to use checksums
6539647262aed2e882105ce505c1012e268e4fd5befa5b70fd12cdba1bf0755f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Release files / bai2_to_csv-0.1.0-py3-none-any.whl

Download URL bai2_to_csv-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71dbb66b6339e4038bb6a9b6c239ffd9610a93b1cf2cfb2871a9f8443d90c40c
BLAKE2b-256 checksum
How to use checksums
516514ea4cb0f23368ea071dfe6df9f173b47edf71e74faf43c1fcffa82987d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

Security for bai2-to-csv 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bai2_to_csv-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page