Python-CFONB
Introduction
The CFONB format is an old file format for banking interchange, made by the CFONB (Comité français d’organisation et de normalisation bancaires). It is still used today to retrieve bank statements or make transfer orders. The specifications of the format can be found on the CFONB website.
python-cfonb is a pure Python lib to read or write CFONB files, distributed under the LGPL license:
import method should read file-like object (with IOString or real plain text file)
export method to export Python object in CFO file
format checker according bank specification: special char, mandatory fields, etc.
The first two usecase are : read bank statements, and make transfer orders
Installation
>>> pip install python-cfonb
Statement Parser
You can read a statement like this:
>>> from os.path import join
>>> statement_file = open(join('cfonb', 'tests', 'bank_statement.cfo'))
>>> from cfonb import StatementReader
>>> reader = StatementReader()
>>> result = reader.parse(statement_file)
>>> statement = result[0]
The statement has a header and a footer, which are both statement rows:
>>> statement.header <cfonb.parser.common.Row object at ...> >>> statement.footer <cfonb.parser.common.Row object at ...>
A row can be read as a list:
>>> statement.header.as_list() ['01', '30002', ' ', '00447', ...]
Or as a dict:
>>> statement.header.as_dict()
{'bank_code': '30002', 'nb_of_dec': ' ', '_5': ...}
Or as an object:
>>> header = statement.header.as_obj() >>> header.bank_code '30002'
The statement lines between the header and the footer can be iterated:
>>> # TODO: use an interator, and hide the parse_amount in the object >>> from cfonb.parser.common import parse_amount >>> for line in statement.lines: ... l = line.as_obj() ... print parse_amount(l.amount, l.nb_of_dec) -2000.0 -1000.0 4000.0 -3000.0
Transfer Writer
Prepare the contents:
>>> from datetime import datetime
>>> from cfonb.writer.transfert import Transfert
>>> transfert = Transfert()
>>> transfert.setEmeteurInfos('2000121','bigbrother','virement de test',503103,2313033,1212,datetime(2011,11,27))
<cfonb.writer.transfert.Transfert instance at ...>
>>> transfert.add('un test','littlebrother','credit agricole ile de france',50011,6565329000,100,'un peu d\'argent',6335)
<cfonb.writer.transfert.Transfert instance at ...>
>>> content = transfert.render()
You can use a filename with render method:
>>> transfert.render(filename='./virement.cfonb') "0302 200012 ..."
Metadata
Release files for python-cfonb 2.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-cfonb-2.13.tar.gz | 13.1 kB | Without provenance | Details for python-cfonb-2.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_cfonb-2.13-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for python_cfonb-2.13-py2.py3-none-any.whl |
Total release size: 30.3 kB
Release files / python-cfonb-2.13.tar.gz
| Download URL | python-cfonb-2.13.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
608094269b29ef7f17bc984d139adcd95cf9800bcd60bbeb88cfdb8ca6916d9a
|
|
BLAKE2b-256 checksum How to use checksums |
4a6bbce06ca5f669c2fbe843d968eae85afb827dbf4c642cdcd2a8f2d892b2b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / python_cfonb-2.13-py2.py3-none-any.whl
| Download URL | python_cfonb-2.13-py2.py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
495059dfadf3ea04be995b1fec2ab82b1a48fa576411bfd8c68222f08e19d967
|
|
BLAKE2b-256 checksum How to use checksums |
5abc3b2e01b95239959852adad815ff871852af42e727089be8ba8138888ef7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for python-cfonb 2.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.