mt-940


Namemt-940 JSON
Version 4.29.0 PyPI version JSON
download
home_pagehttps://github.com/WoLpH/mt940
SummaryA library to parse MT940 files and returns smart Python collections for statistics and manipulation.
upload_time2023-03-27 02:30:32
maintainer
docs_urlNone
authorRick van Hattem (wolph)
requires_python
licenseBSD
keywords mt940
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =====
MT940
=====

.. image:: https://github.com/wolph/mt940/actions/workflows/main.yml/badge.svg?branch=master
    :alt: MT940 test status
    :target: https://github.com/wolph/mt940/actions/workflows/main.yml

.. image:: https://badge.fury.io/py/mt-940.svg
    :alt: MT940 Pypi version
    :target: https://pypi.python.org/pypi/mt-940

.. image:: https://coveralls.io/repos/WoLpH/mt940/badge.svg?branch=master
    :alt: MT940 code coverage
    :target: https://coveralls.io/r/WoLpH/mt940?branch=master

.. image:: https://img.shields.io/pypi/pyversions/mt-940.svg

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

Links
-----

* Documentation
    - http://mt940.readthedocs.org/en/latest/
* Source
    - https://github.com/WoLpH/mt940
* Bug reports 
    - https://github.com/WoLpH/mt940/issues
* Package homepage
    - https://pypi.python.org/pypi/mt-940
* My blog
    - http://wol.ph/

Install
-------

To install the latest release:

.. code-block:: bash

    pip install mt-940

Or if `pip` is not available:
    
.. code-block:: bash

    easy_install mt-940
   
To install the latest development release:

.. code-block:: bash

    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:

.. code-block:: python

   import mt940
   import pprint

   transactions = mt940.parse('mt940_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:

.. code-block:: python

   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('mt940_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:

.. code-block:: python

    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:

.. code-block:: python

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

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

    trs.parse(ASNB_mt940_data)
    trs_data = pprint.pformat(trs.data, sort_dicts=False)
    print(trs_data)

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:

.. code-block:: shell

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

Or to run the tests on all available Python versions:

.. code-block:: shell

    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        .. code-block:: bash

                    $ git clone https://github.com/WoLpH/mt940.git
install dev     .. code-block:: bash

                    $ git clone https://github.com/WoLpH/mt940.git mt940
                    $ cd ./mt940
                    $ virtualenv .env
                    $ source .env/bin/activate
                    $ pip install -e .
tests           .. code-block:: bash

                    $ py.test
==============  ==========================================================

.. _BSD: http://opensource.org/licenses/BSD-3-Clause
.. _Documentation: http://mt940.readthedocs.org/en/latest/
.. _API: http://mt940.readthedocs.org/en/latest/modules.html

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/WoLpH/mt940",
    "name": "mt-940",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "MT940",
    "author": "Rick van Hattem (wolph)",
    "author_email": "wolph@wol.ph",
    "download_url": "https://files.pythonhosted.org/packages/bd/3d/1b71c54313585228debb47ebef87f8c8f289a1275dc7603c1367e02e2bd8/mt-940-4.29.0.tar.gz",
    "platform": null,
    "description": "=====\nMT940\n=====\n\n.. image:: https://github.com/wolph/mt940/actions/workflows/main.yml/badge.svg?branch=master\n    :alt: MT940 test status\n    :target: https://github.com/wolph/mt940/actions/workflows/main.yml\n\n.. image:: https://badge.fury.io/py/mt-940.svg\n    :alt: MT940 Pypi version\n    :target: https://pypi.python.org/pypi/mt-940\n\n.. image:: https://coveralls.io/repos/WoLpH/mt940/badge.svg?branch=master\n    :alt: MT940 code coverage\n    :target: https://coveralls.io/r/WoLpH/mt940?branch=master\n\n.. image:: https://img.shields.io/pypi/pyversions/mt-940.svg\n\n``mt940`` - A library to parse MT940 files and returns smart Python collections\nfor statistics and manipulation.\n\nLinks\n-----\n\n* Documentation\n    - http://mt940.readthedocs.org/en/latest/\n* Source\n    - https://github.com/WoLpH/mt940\n* Bug reports \n    - https://github.com/WoLpH/mt940/issues\n* Package homepage\n    - https://pypi.python.org/pypi/mt-940\n* My blog\n    - http://wol.ph/\n\nInstall\n-------\n\nTo install the latest release:\n\n.. code-block:: bash\n\n    pip install mt-940\n\nOr if `pip` is not available:\n    \n.. code-block:: bash\n\n    easy_install mt-940\n   \nTo install the latest development release:\n\n.. code-block:: bash\n\n    git clone --branch develop https://github.com/WoLpH/mt940.git mt940\n    cd ./mt940\n    virtualenv .env\n    source .env/bin/activate\n    pip install -e .\n\nTo run the tests you can use the `py.test` command or just run `tox` to test\neverything in all supported python versions.\n\nUsage\n-----\n\nBasic parsing:\n\n.. code-block:: python\n\n   import mt940\n   import pprint\n\n   transactions = mt940.parse('mt940_tests/jejik/abnamro.sta')\n\n   print('Transactions:')\n   print(transactions)\n   pprint.pprint(transactions.data)\n\n   print()\n   for transaction in transactions:\n       print('Transaction: ', transaction)\n       pprint.pprint(transaction.data)\n\n\nSet opening / closing balance information on each transaction:\n\n.. code-block:: python\n\n   import mt940\n   import pprint\n\n   mt940.tags.BalanceBase.scope = mt940.models.Transaction\n\n   # The currency has to be set manually when setting the BalanceBase scope to Transaction.\n   transactions = mt940.models.Transactions(processors=dict(\n       pre_statement=[\n           mt940.processors.add_currency_pre_processor('EUR'),\n       ],\n   ))\n\n   with open('mt940_tests/jejik/abnamro.sta') as f:\n       data = f.read()\n\n   transactions.parse(data)\n\n   for transaction in transactions:\n       print('Transaction: ', transaction)\n       pprint.pprint(transaction.data)\n\nSimple json encoding:\n\n.. code-block:: python\n\n    import json\n    import mt940\n\n\n    transactions = mt940.parse('mt940_tests/jejik/abnamro.sta')\n\n    print(json.dumps(transactions, indent=4, cls=mt940.JSONEncoder))\n\nParsing statements from the Dutch bank ASN where tag 61 does not follow the Swift specifications:\n\n.. code-block:: python\n\n    def ASNB_mt940_data():\n        with open('mt940_tests/ASNB/0708271685_09022020_164516.940.txt') as fh:\n            return fh.read()\n\n    def test_ASNB_tags(ASNB_mt940_data):\n        tag_parser = mt940.tags.StatementASNB()\n        trs = mt940.models.Transactions(tags={\n            tag_parser.id: tag_parser\n        })\n\n    trs.parse(ASNB_mt940_data)\n    trs_data = pprint.pformat(trs.data, sort_dicts=False)\n    print(trs_data)\n\nContributing\n------------\n\nHelp is greatly appreciated, just please remember to clone the **development**\nbranch and to run `tox` before creating pull requests.\n\nTravis tests for `flake8` support and test coverage so it's always good to\ncheck those before creating a pull request.\n\nDevelopment branch: https://github.com/WoLpH/mt940/tree/develop\n\nTo run the tests:\n\n.. code-block:: shell\n\n    pip install -r mt940_tests/requirements.txt\n    py.test\n\nOr to run the tests on all available Python versions:\n\n.. code-block:: shell\n\n    pip install tox\n    tox\n\nInfo\n----\n\n==============  ==========================================================\nPython support  Python 2.7, >= 3.3\nBlog            http://wol.ph/\nSource          https://github.com/WoLpH/mt940\nDocumentation   http://mt940.rtfd.org\nChangelog       http://mt940.readthedocs.org/en/latest/history.html\nAPI             http://mt940.readthedocs.org/en/latest/modules.html\nIssues/roadmap  https://github.com/WoLpH/mt940/issues\nTravis          http://travis-ci.org/WoLpH/mt940\nTest coverage   https://coveralls.io/r/WoLpH/mt940\nPypi            https://pypi.python.org/pypi/mt-940\nOhloh           https://www.ohloh.net/p/mt-940\nLicense         `BSD`_.\ngit repo        .. code-block:: bash\n\n                    $ git clone https://github.com/WoLpH/mt940.git\ninstall dev     .. code-block:: bash\n\n                    $ git clone https://github.com/WoLpH/mt940.git mt940\n                    $ cd ./mt940\n                    $ virtualenv .env\n                    $ source .env/bin/activate\n                    $ pip install -e .\ntests           .. code-block:: bash\n\n                    $ py.test\n==============  ==========================================================\n\n.. _BSD: http://opensource.org/licenses/BSD-3-Clause\n.. _Documentation: http://mt940.readthedocs.org/en/latest/\n.. _API: http://mt940.readthedocs.org/en/latest/modules.html\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A library to parse MT940 files and returns smart Python collections for statistics and manipulation.",
    "version": "4.29.0",
    "split_keywords": [
        "mt940"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "293ebde19c6ba237cc715326820102664fdeb656d8aca0ab8db81d4773174dad",
                "md5": "8680c56e4e2481f06239d7656e111c6e",
                "sha256": "5f548af024276c6fbca3b0039d9f4b779e2986986d8d7a5835263a27df82a0aa"
            },
            "downloads": -1,
            "filename": "mt_940-4.29.0-py2.py3-none-any.whl",
            "has_sig": true,
            "md5_digest": "8680c56e4e2481f06239d7656e111c6e",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 19285,
            "upload_time": "2023-03-27T02:30:29",
            "upload_time_iso_8601": "2023-03-27T02:30:29.961738Z",
            "url": "https://files.pythonhosted.org/packages/29/3e/bde19c6ba237cc715326820102664fdeb656d8aca0ab8db81d4773174dad/mt_940-4.29.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd3d1b71c54313585228debb47ebef87f8c8f289a1275dc7603c1367e02e2bd8",
                "md5": "43804704eeecf15d71401e3d32da4902",
                "sha256": "f7795740b8fd2ce7d963163867bb76ebd1b593f6798fcc9e5f319a05b9a2dd78"
            },
            "downloads": -1,
            "filename": "mt-940-4.29.0.tar.gz",
            "has_sig": true,
            "md5_digest": "43804704eeecf15d71401e3d32da4902",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20950,
            "upload_time": "2023-03-27T02:30:32",
            "upload_time_iso_8601": "2023-03-27T02:30:32.484213Z",
            "url": "https://files.pythonhosted.org/packages/bd/3d/1b71c54313585228debb47ebef87f8c8f289a1275dc7603c1367e02e2bd8/mt-940-4.29.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-27 02:30:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "WoLpH",
    "github_project": "mt940",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "mt-940"
}
        
Elapsed time: 0.04767s