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:
- A transaction summary file containing aggregated transaction information
- 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:
- Test Matrix: Run tests on Python 3.9, 3.10, 3.11, and 3.12
- Quality Checks: Format, imports, linting, and type checking
- Unit Tests: Complete test suite with coverage reporting
- Integration Tests: End-to-end workflow testing
- Coverage Reporting: Upload coverage to Codecov
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c381e5a140de022cbde76d61c3378cbca929ea0bda04946693293080febd0997
|
|
| MD5 |
dd54559b3ea388fda94e79294fad5200
|
|
| BLAKE2b-256 |
6539647262aed2e882105ce505c1012e268e4fd5befa5b70fd12cdba1bf0755f
|
Provenance
The following attestation bundles were made for bai2_to_csv-0.1.0.tar.gz:
Publisher:
publish.yml on hengpor/bai2-to-csv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bai2_to_csv-0.1.0.tar.gz -
Subject digest:
c381e5a140de022cbde76d61c3378cbca929ea0bda04946693293080febd0997 - Sigstore transparency entry: 2732933395
- Sigstore integration time:
-
Permalink:
hengpor/bai2-to-csv@d4076087e713ac830072206c9bb7074dcd24c95e -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/hengpor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d4076087e713ac830072206c9bb7074dcd24c95e -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71dbb66b6339e4038bb6a9b6c239ffd9610a93b1cf2cfb2871a9f8443d90c40c
|
|
| MD5 |
658d7b91df28393b284e5e46e1ce0fdb
|
|
| BLAKE2b-256 |
516514ea4cb0f23368ea071dfe6df9f173b47edf71e74faf43c1fcffa82987d3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bai2_to_csv-0.1.0-py3-none-any.whl -
Subject digest:
71dbb66b6339e4038bb6a9b6c239ffd9610a93b1cf2cfb2871a9f8443d90c40c - Sigstore transparency entry: 2732933463
- Sigstore integration time:
-
Permalink:
hengpor/bai2-to-csv@d4076087e713ac830072206c9bb7074dcd24c95e -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/hengpor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d4076087e713ac830072206c9bb7074dcd24c95e -
Trigger Event:
release
-
Statement type: