Skip to content
A library to parse MT940 files and returns smart Python collections for statistics and manipulation.
Python Makefile
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create stale.yml Feb 15, 2019
docs modernized setup.py May 11, 2018
mt940 Incrementing version to v4.17.0 May 31, 2019
tests relax detail parsing to ignore malformed segments May 30, 2019
.coveragerc added support for NS data Jun 26, 2016
.gitignore
.travis.yml remove python3.3 from travis.yml Dec 23, 2017
AUTHORS.rst merging... Apr 25, 2016
CHANGES modernized setup.py May 11, 2018
CONTRIBUTING.rst python 3 support to fix #10 Jul 11, 2015
LICENSE added initial version of mt940 parser, fully functional Apr 9, 2014
MANIFEST.in Include tests in PyPI tarball Mar 19, 2019
Makefile python 3 support to fix #10 Jul 11, 2015
README.rst updated json readme Mar 6, 2019
pytest.ini ignore .eggs dir from pytest checks Dec 23, 2017
requirements.txt
setup.cfg added support for NS data Jun 26, 2016
setup.py fixed travis test May 11, 2018
tox.ini remove python3.3 from tox as it conflicts with pytest Dec 23, 2017

README.rst

MT940

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.

Links

Install

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 https://github.com/WoLpH/mt940.git 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.

Usage

Basic parsing:

import mt940
import pprint

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

print 'Transactions:'
print transactions
pprint.pprint(transactions.data)

print
for transaction in transactions:
    print 'Transaction: ', transaction
    pprint.pprint(transaction.data)

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(
    pre_statement=[
        mt940.processors.add_currency_pre_processor('EUR'),
    ],
))

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

transactions.parse(data)

for transaction in transactions:
    print 'Transaction: ', transaction
    pprint.pprint(transaction.data)

Simple json encoding:

import json
import mt940


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

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

Contributing

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: https://github.com/WoLpH/mt940/tree/develop

To run the tests:

pip install -r tests/requirements.txt
py.test

Or to run the tests on all available Python versions:

pip install tox
tox

Info

Python support Python 2.7, >= 3.3
Blog http://wol.ph/
Source https://github.com/WoLpH/mt940
Documentation http://mt940.rtfd.org
Changelog http://mt940.readthedocs.org/en/latest/history.html
API http://mt940.readthedocs.org/en/latest/modules.html
Issues/roadmap https://github.com/WoLpH/mt940/issues
Travis http://travis-ci.org/WoLpH/mt940
Test coverage https://coveralls.io/r/WoLpH/mt940
Pypi https://pypi.python.org/pypi/mt-940
Ohloh https://www.ohloh.net/p/mt-940
License BSD.
git repo
$ git clone https://github.com/WoLpH/mt940.git
install dev
$ git clone https://github.com/WoLpH/mt940.git mt940
$ cd ./mt940
$ virtualenv .env
$ source .env/bin/activate
$ pip install -e .
tests
$ py.test
You can’t perform that action at this time.