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.

Download files

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

Source Distribution

bai2_to_csv-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

bai2_to_csv-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bai2_to_csv-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for bai2_to_csv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c381e5a140de022cbde76d61c3378cbca929ea0bda04946693293080febd0997
MD5 dd54559b3ea388fda94e79294fad5200
BLAKE2b-256 6539647262aed2e882105ce505c1012e268e4fd5befa5b70fd12cdba1bf0755f

See more details on using hashes here.

Provenance

The following attestation bundles were made for bai2_to_csv-0.1.0.tar.gz:

Publisher: publish.yml on hengpor/bai2-to-csv

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

File details

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

File metadata

  • Download URL: bai2_to_csv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for bai2_to_csv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71dbb66b6339e4038bb6a9b6c239ffd9610a93b1cf2cfb2871a9f8443d90c40c
MD5 658d7b91df28393b284e5e46e1ce0fdb
BLAKE2b-256 516514ea4cb0f23368ea071dfe6df9f173b47edf71e74faf43c1fcffa82987d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bai2_to_csv-0.1.0-py3-none-any.whl:

Publisher: publish.yml on hengpor/bai2-to-csv

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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