Skip to main content

mt940-camt053

Convert bank statements between SWIFT MT940 and ISO 20022 CAMT.053, in both directions, or flatten either one to CSV or Excel (.xlsx). Pure Python + lxml. Runs on your machine: no network, no upload.

Banks are retiring MT940 in favour of CAMT.053, while many ERP and accounting systems still read only one of the two. This library reads both into one statement model and writes either format back, and it checks that opening balance + entries = closing balance for every statement.

No install? The same engine runs in the browser: MT940 to CAMT.053 online converter.

Install

pip install mt940-camt053
pip install "mt940-camt053[excel]"    # adds openpyxl for .xlsx output

Command line

mt940-camt053 statement.sta                 # MT940 -> statement-camt053.xml (camt.053.001.08)
mt940-camt053 statement.xml                 # CAMT.053 -> statement.sta (MT940)
mt940-camt053 statement.sta --to csv        # one row per transaction
mt940-camt053 statement.xml --to xlsx       # Excel: numbers, dates, balances sheet
mt940-camt053 *.sta --version 001.02        # older CAMT version for older systems
mt940-camt053 in.xml --to mt940 -o out.sta

Each file prints one line: transactions, statements and the balance check result. Exit code 1 if a file could not be read.

Python

import mt940_camt053 as mc

stmts = mc.load("statement.sta")      # MT940, CAMT.053 or camt.052 - found out by itself
xml   = mc.to_camt053(stmts)          # bytes, camt.053.001.08 (or version="001.02")
text  = mc.to_mt940(stmts)            # str, CRLF lines, SWIFT character set
table = mc.to_csv(stmts)              # str, columns in mc.CSV_COLUMNS
mc.to_xlsx(stmts, "statement.xlsx")   # Excel: 'Transactions' + 'Statements' (balances, check)

for st in stmts:
    state, diff = mc.balance_check(st)        # "ok" | "bad" | "none"
    for t in st["txs"]:
        print(t["bdate"], t["amt"], t["name"], t["iban"], t["remit"])

mc.loads(data, name) takes bytes. mc.convert_file(src, dst, to="auto") converts a file on disk and returns a small summary.

What it reads

Format Details
MT940 Tags :20: :25: :28C: :60F/M: :61: :86: :62F/M: :64:, several statements per file, {1:}{2:}{4: -} envelopes, CRLF or LF
:86: text German structured fields (?20..?29 purpose, ?30 BIC, ?31 IBAN, ?32/?33 name), /EREF/../NAME/../REMI/.. and EREF+ / SVWZ+ / MREF+ keywords
Encodings UTF-8 (with or without BOM), cp1252, latin-1, UTF-16
CAMT camt.053 and camt.052, any version (the namespace is ignored), Stmt or Rpt

What it writes

Format Details
CAMT.053 camt.053.001.08 (default) or camt.053.001.02, elements in schema order, reversals as RvslInd=true
MT940 :61: and :86: with SWIFT line lengths; umlauts and Cyrillic are transliterated to the SWIFT character set
Excel (.xlsx) Sheet Transactions (same columns as CSV, amounts as numbers with negatives in red, real dates, frozen header, filter) and sheet Statements (opening/closing balance, balance check per statement)
CSV Signed amounts (negative = money out), booking and value date, counterparty name, IBAN, BIC, remittance text, end-to-end id, mandate id, references

Transaction fields

bdate, vdate (dates), amt (Decimal, signed), rev (reversal), name, iban, bic, remit (remittance text), e2e (end-to-end id), mndt (mandate id), bref (bank reference), cref (customer reference), type, gvc, text, supp.

A statement has ref, acct, seq, cur, open, close, avail (balances with amt, date, cur) and txs.

Limits, said plainly

  • MT940 carries less than CAMT.053. Going CAMT -> MT940 cuts long texts at 6 lines of 65 characters and drops what MT940 has no place for; notes tells you when that happened.
  • Going MT940 -> CAMT.053 can only fill what the MT940 file holds. Structured party data exists only if the bank wrote it in :86:.
  • PDF or scanned statements are not read (that needs OCR).
  • Bank dialects of :86: differ. If a file from your bank is read wrongly, the numbers are still copied as they are and the balance check tells you whether the statement adds up.

MIT licence. Made by Radar.

Metadata

Release files for mt940-camt053 0.2.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 mt940-camt053 0.2.0
File Size Uploaded Provenance Actions
mt940_camt053-0.2.0.tar.gz 20.9 kB Without provenance Details for mt940_camt053-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mt940-camt053 0.2.0
File Interpreter ABI Platform Actions
mt940_camt053-0.2.0-py3-none-any.whl Python 3 none any Details for mt940_camt053-0.2.0-py3-none-any.whl

Total release size: 38.1 kB

Release files / mt940_camt053-0.2.0.tar.gz

Download URL mt940_camt053-0.2.0.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0817327d2a351208f16568617368e6cfcfac54b95a7bdddc8a1279b8f230f293
BLAKE2b-256 checksum
How to use checksums
f57df85eaeb1d828586fa99b70f47927ff3a2044b76d2471f267e50a3342a7f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / mt940_camt053-0.2.0-py3-none-any.whl

Download URL mt940_camt053-0.2.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2eab168acebd621e6e362201fb04df31da59ed65347c2687addcbe26e8c91455
BLAKE2b-256 checksum
How to use checksums
37e4171bbb0e45dc61f385a80fa089dd3e63b0bb83649cc14ef8fef5bf7d545c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for mt940-camt053 0.2.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.

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.

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