A library to parse MT940 files and returns smart Python collections for statistics and manipulation.
Project description
mt940 - A library to parse MT940 files and returns smart Python collections for statistics and manipulation.
Links
- Documentation
- Bug reports
- Package homepage
- My blog
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') def default(value): if isinstance(value, mt940.models.Transactions): data = value.data.copy() data['transactions'] = value.transactions return data elif hasattr(value, 'data'): return value.data print(json.dumps(transactions, default=default, indent=4))
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 |
|
Source |
|
Documentation |
|
Changelog |
|
API |
|
Issues/roadmap |
|
Travis |
|
Test coverage |
|
Pypi |
|
Ohloh |
|
License |
BSD. |
git repo |
|
install dev |
|
tests |
|
Changelog
v4.12.1 modernized setup.py and reformatted pypi readme v4.12.1
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mt_940-4.12.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7a6b4ba78a9b449d2726678e1f10d0b16490cad42b1c44b759fd3cc8914aca8 |
|
MD5 | 421da1082f9d4767c28e455c53dfa2b4 |
|
BLAKE2b-256 | 4e47fd1e308511d0e7cf2b457a941b399a0faa3a346b2d0aa733cf485688204f |