x940
High-performance MT940 bank statement parser. Converts legacy SWIFT MT940 files to JSON, CSV, and ISO 20022 camt.053 XML — built in Rust with Python bindings via PyO3.
Installation
pip install x940
Requires Python 3.8+.
Quick Start
import x940 as x
stmt = x.MT940(open("statement.sta").read())
# statement info
stmt.account # "EUR8934567890123456"
stmt.currency # "EUR"
stmt.opening_balance # 50000.0
stmt.closing_balance # 51500.75
stmt.resolver_used # "auto"
# transactions
len(stmt.transactions) # 3
tx = stmt.transactions[0]
tx.value_date # "2026-06-01"
tx.amount # -1500.0 (signed: negative for debits)
tx.debit_credit # "D"
tx.is_debit # True
tx.customer_reference # "INV-2026-991"
tx.counterparty # "ALPHA DIGITAL CORP"
tx.purpose # "MONTHLY RETAINER FEES"
# export
stmt.to_json() # JSON string
stmt.to_csv() # CSV string with UTF-8 BOM
stmt.to_camt053() # camt.053.001.06 XML
Dialect Detection
Tag 86 (transaction details) comes in several regional formats. x940 auto-detects the dialect per-transaction using a chain of decoders:
| Resolver | Format | Use case |
|---|---|---|
auto |
Auto-detect (default) | Mixed-source files |
swift |
/KEYWORD/VALUE structured |
SWIFT-structured statements |
gvc |
German ?DDKeyValue |
German bank statements |
angular |
Polish/Nordic <DD / ^DD |
Polish, Nordic banks |
Specify a resolver to prefer a specific dialect (unmatched transactions fall back to unstructured):
stmt = x.MT940(data, resolver="gvc")
stmt.resolver_used # "gvc"
Transaction Properties
| Property | Type | Description |
|---|---|---|
value_date |
str |
Value date (YYYY-MM-DD) |
entry_date |
str or None |
Entry date (YYYY-MM-DD) |
debit_credit |
str |
"D" (debit), "C" (credit), etc. |
amount |
float |
Signed amount (negative = debit) |
is_credit |
bool |
True if this is a credit entry |
is_debit |
bool |
True if this is a debit entry |
is_reversal |
bool |
True if this is a reversal entry |
transaction_type |
str |
SWIFT transaction type code |
customer_reference |
str |
Customer reference from :86: |
bank_reference |
str or None |
Bank reference |
details |
str |
Raw Tag 86 detail text |
structured_details |
dict or None |
Parsed key-value map |
counterparty |
str |
Resolved counterparty name |
counter_iban |
str |
Resolved counterparty IBAN |
purpose |
str |
Resolved remittance/purpose text |
signed_amount() |
float |
Same as amount property |
Export Formats
| Method | Output | Description |
|---|---|---|
to_json() |
str |
JSON array of statements |
to_csv() |
str |
CSV with UTF-8 BOM, signed amounts |
to_camt053() |
str |
ISO 20022 camt.053.001.06 XML |
License
GPL-3.0-or-later. See LICENSE.
Links
Metadata
Release files for x940 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| x940-0.1.1.tar.gz | 49.8 kB | Without provenance | Details for x940-0.1.1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| x940-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.34+ x86-64 | Details for x940-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl |
| x940-0.1.1-cp310-cp310-macosx_11_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 11.0+ ARM64 | Details for x940-0.1.1-cp310-cp310-macosx_11_0_arm64.whl |
Total release size: 1.7 MB
Release files / x940-0.1.1.tar.gz
| Download URL | x940-0.1.1.tar.gz |
|---|---|
| Size | 49.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7e14249a2d2bd23e5eb3b3f04e18a3dafba8461cd65b06bd3dc6e35fbc82ff8
|
|
BLAKE2b-256 checksum How to use checksums |
2d20975f96b0799d06fce87477eb289654a8f6d2a0be2ae3382776f284d78340
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / x940-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | x940-0.1.1-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 878.0 kB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
82fb814516b57f19e9eabbb3a5dc4b5803621ed6d795c068e39b9ee8221dc1cb
|
|
BLAKE2b-256 checksum How to use checksums |
793a24f2a0f7af5d973ffdc4c5222f91e139c00cb50adce7e31f24b28b66ce18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / x940-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | x940-0.1.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 785.5 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
aebbdad0364ba72f7aa2ca78a12764d8e5648b39074f16e38091039a08f65318
|
|
BLAKE2b-256 checksum How to use checksums |
10ca59cce9cdb8eef0630f7d1f34391e379ddac0ed41cc75f9a756e90a225d19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Security for x940 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.