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. 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

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 *.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

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
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.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 mt940-camt053 0.1.0
File Size Uploaded Provenance Actions
mt940_camt053-0.1.0.tar.gz 19.2 kB Without provenance Details for mt940_camt053-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 35.3 kB

Release files / mt940_camt053-0.1.0.tar.gz

Download URL mt940_camt053-0.1.0.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
800e87f15c6ed493fda25b3fad193b77243b51e018cfa4f52f96f87ccdc7fff0
BLAKE2b-256 checksum
How to use checksums
7c47d5c43d88a37380a70199af73bfb06d6902406e80cad1e7bb9fe83d6feaf9
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.1.0-py3-none-any.whl

Download URL mt940_camt053-0.1.0-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67b1c3260ec850885ccf4caf127cdadc0c8302eeab317a1b4c537604e2bc4cd9
BLAKE2b-256 checksum
How to use checksums
5136c53fcd7c0e94b73aac6ed2cf4817ef4dd8c2563f6b67824d627ec1f08abb
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.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.

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