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.

Open a CAMT.053 or MT940 file in Excel

Your bank gave you a CAMT.053 (.xml) or MT940 (.sta, .940, .txt) statement and you want it in Excel:

  1. pip install "mt940-camt053[excel]"
  2. mt940-camt053 statement.xml --to xlsx (or --to csv), the same for an MT940 file.
  3. Open statement.xlsx: one row per transaction with date, amount, counterparty, IBAN and reference, plus a balances sheet. The command prints whether opening balance + transactions = closing balance, so you know nothing is missing.

No install: free online CAMT.053 to Excel and MT940 to Excel converters.

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

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.1
File Size Uploaded Provenance Actions
mt940_camt053-0.2.1.tar.gz 21.3 kB Without provenance Details for mt940_camt053-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 38.8 kB

Release files / mt940_camt053-0.2.1.tar.gz

Download URL mt940_camt053-0.2.1.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a19e6701475d5c257f0dbfe79f647bd7b24d65a748e7a897c1edc5303f0d23a3
BLAKE2b-256 checksum
How to use checksums
8376bca5f951ebfa7e3cbf39d2e96c13e039220461a00acb5ea8d4d5eb07649b
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.1-py3-none-any.whl

Download URL mt940_camt053-0.2.1-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0d1cf8f7e20be896af5597556bf023d130eaf3af07f558a17aca2aeef574d0c
BLAKE2b-256 checksum
How to use checksums
bd24930292292d1fd11733c2bbfd104ceb0e9bb832ced4c81283266081cb720e
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.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.

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