Skip to main content

A library to parse MT940 files and returns smart Python collections for statistics and manipulation.

Project description

MT940 test status MT940 Pypi version MT940 code coverage

mt940 - A library to parse MT940 files and returns smart Python collections for statistics and manipulation.


To install the latest release:

pip install mt-940

Or if pip is not available:

easy_install mt-940

To install the latest development release:

git clone --branch develop mt940
cd ./mt940
virtualenv .env
source .env/bin/activate
pip install -e .

To run the tests you can use the py.test command or just run tox to test everything in all supported python versions.


Basic parsing:

import mt940
import pprint

transactions = mt940.parse('mt940_tests/jejik/abnamro.sta')


for transaction in transactions:
    print('Transaction: ', transaction)

Set opening / closing balance information on each transaction:

import mt940
import pprint

mt940.tags.BalanceBase.scope = mt940.models.Transaction

# The currency has to be set manually when setting the BalanceBase scope to Transaction.
transactions = mt940.models.Transactions(processors=dict(

with open('mt940_tests/jejik/abnamro.sta') as f:
    data =


for transaction in transactions:
    print('Transaction: ', transaction)

Simple json encoding:

import json
import mt940

transactions = mt940.parse('mt940_tests/jejik/abnamro.sta')

print(json.dumps(transactions, indent=4, cls=mt940.JSONEncoder))

Parsing statements from the Dutch bank ASN where tag 61 does not follow the Swift specifications:

def ASNB_mt940_data():
    with open('mt940_tests/ASNB/0708271685_09022020_164516.940.txt') as fh:

def test_ASNB_tags(ASNB_mt940_data):
    tag_parser = mt940.tags.StatementASNB()
    trs = mt940.models.Transactions(tags={ tag_parser

trs_data = pprint.pformat(, sort_dicts=False)


Help is greatly appreciated, just please remember to clone the development branch and to run tox before creating pull requests.

Travis tests for flake8 support and test coverage so it’s always good to check those before creating a pull request.

Development branch:

To run the tests:

pip install -r mt940_tests/requirements.txt

Or to run the tests on all available Python versions:

pip install tox


Python support Python 2.7, >= 3.3
Test coverage
License BSD.
git repo
$ git clone
install dev
$ git clone mt940
$ cd ./mt940
$ virtualenv .env
$ source .env/bin/activate
$ pip install -e .
$ py.test


  • v4.23.0 added optional support for spaces in extra details post processor to fix #85 v4.23.0
  • v4.22.0 added support for more “additional purpose” keys to fix #85 v4.22.0
  • v4.21.0 improved performance to scale linear instead of quadratic v4.21.0
  • v4.20.0 Added tag 61 support for the ASN bank thanks to @gpaulissen v4.20.0
  • v4.19.0 Parsing GV codes anywhere in purpose thanks to @bdabelow v4.19.0
  • v4.18.0 renamed tests to mt940_tests to fix #78 v4.18.0
  • v4.16.0 improved non-swift support for banks using different standards. Fixes #74 v4.16.0
  • v4.15.0 Including tests in package v4.15.0
  • v4.13.2 Fixed python 3 tests v4.13.2
  • v4.13.1 fixed windows bug when directly passing data. Fixes #68 v4.13.1
  • v4.13.0 Improved entry date handling and added workaround for banks using too much whitespace v4.13.0
  • v4.12.2 Relaxed regexes for Fiducia/Volksbank Ortenau thanks to @jahir v4.12.2
  • v4.11.0 Fixes #56: Transaction details parsing error if content is unfortunately wrapped v4.11.0
  • v4.10.0 Fixed overzealous whitespace trimming thanks to @FelixSchwarz and added :61: support for Sberbank thanks to @csfulop v4.10.0
  • v4.9.0 Fixed #47 and #48 thanks to @sbi v4.9.0
  • v4.8.1 removed debug statement thanks to @robfech v4.8.1
  • v4.8.0 Added German transaction details parsing (#30, thanks to @sweh) and fixed february 29th support (#45, thanks to @fHachenberg) v4.8.0
  • v4.7 Fixed #42 thanks to @cluck. NS records are now parsed correctly v4.7
  • v4.6 Fixed #42 thanks to @cluck. NS records are now parsed correctly v4.6
  • v4.5 fixed wrong repetitions cound in TransactionDetails (fixes #37) v4.5
  • v4.4 Added support for mBank Collect and fixed MT942 support thanks to @sq9mev v4.4
  • v4.3 Added mt942 support thanks to @bumi
  • v4.2 Added single input agnostic parse method. Thanks to @philippeowagner
  • v4.1 Added NS (non-swift) support. Fixes #23
  • v4.0 Added support for many more MT940 variants
  • v3.2 Added support for intermediate/final closing/opening balance
  • v3.1 Fixed #12. Previously matched tags in the middle of the line
  • v3.0 Added Python 3 support
  • v2.0 Version 2.0 with 100% test coverage and better docs

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mt-940, version 4.23.0
Filename, size File type Python version Upload date Hashes
Filename, size mt_940-4.23.0-py2.py3-none-any.whl (283.2 kB) File type Wheel Python version 3.8 Upload date Hashes View
Filename, size mt-940-4.23.0.tar.gz (69.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page