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 |
|
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
File details
Details for the file mt-940-4.13.1.tar.gz
.
File metadata
- Download URL: mt-940-4.13.1.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa41d3809016233ac3a8c7d77e5ce5275d5e5fd80d5effd6be13a6394f2226da |
|
MD5 | 350aa056bd8987729c74719b7cdb41cd |
|
BLAKE2b-256 | d794ace22740493d86f3b2bf06e3e321eed8dcdb1fb3a11e05b86eb6e9da50ec |
File details
Details for the file mt_940-4.13.1-py2.py3-none-any.whl
.
File metadata
- Download URL: mt_940-4.13.1-py2.py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70646129a703b0362eab360dec3a93e86a45bff902d227f869f36da899d831ec |
|
MD5 | 21d395e26ab332f94f76c87487833c74 |
|
BLAKE2b-256 | 15083d73828501e38d6e9d8f25a0bde7818a6bb095dda98d2d1841f8f7df0960 |