Skip to main content

A framework to read and write OFX files Version 1.

Project description

Detailed Documentation

EDOFX Framework

EDOFX is a python framework / DSL to manipulate OFX Version 1 files.

EDOFX has no dependencies other than Python standard library.

EDOFX has been tested with python 2.5 to 2.7.

Python 3 is not supported yet.

Content of this file

  • Licence
  • Installation
  • Usage
    • Parse an OFX file or string
    • Inspect and manipulate OFX file
      • Navigate OFX tree
      • [[Home|Iterators]]
      • Indexers
      • Delete Nodes
      • Modify Nodes
    • OFX tree display and export
  • Package Description
      • OFXNode
      • OFXParser
      • OFXObfuscator
    • test directory description


EDOFX is licensed under MIT License. See LICENCE.txt


From pypi

Use pip or easy_install:

$ pip install inouk.edofx
$ easy_install inouk.edofx
From source

Git clone from the official repository then install with:

python install


Parse an OFX file or string

To experiment, create a virtualenv, install inouk.edofx then launch python and use:

>>> from inouk import edofx
>>> f = open('test/fixtures/multi_account_file.ofx', 'U')  # Files must be opened using 'U' mode as the parser do not manage \r\n EOL
>>> OFX = edofx.OFXParser(
>>> OFX

OFX now contains an OFXNode’s tree representation of test/fixtures/multi_account_file.ofx.

Inspect and manipulate the OFX tree

To navigate OFX tree, use :

>>> OFX.children
[<STATUS>...</STATUS>, <DTSERVER>20100305094649, <LANGUAGE>FRA]
'20100305094649' # This is the raw value as a string
>>> OFX.SIGNONMSGSRSV1.SONRS.DTSERVER.val # returns date or float when appropriate, 3, 5)

Iterators are ok:

>>> # To list account numbers present in file
>>> for account in OFX.BANKMSGSRSV1.STMTTRNRS:
...     print 'account #', account.TRNUID.val
account # 34995678052
account # 85576218690
account # 44498008728
account # 42025380697
account # 62631064788

Indexers are ok:


Modify nodes

To delete nodes:

>>> OFX.children
>>> del OFX.CREDITCARDMSGSRSV1 # Warning does not work (yet) on indexed items
>>> OFX.children

To modify nodes:

For that purpose, you must let ‘.value’ with a string. Note that ‘.val’ attribute is not ( yet ) writable.


To alter Tree structure:

>>> OFX.SIGNONMSGSRSV1.SONRS.children.append(edofx.OFXNode(name='COLOR', value='blue')) # insert is ok too
[<STATUS>...</STATUS>, <DTSERVER>20100305094649, <LANGUAGE>Italian, <COLOR>blue]
OFX tree display and export

OFXNode supports 3 output / dump formats :

  • OFX ; to re-export as OFX after tree/nodes modifications
  • XML ; easier to read
  • Obfuscated ; re-export as OFX with all sensitive information jammed.

Important information: Nodes ‘ACCTTYPE’, ‘CODE’, ‘STATUS’, ‘SEVERITY’, ‘LANGUAGE’, ‘CURDEF’, ‘TRNTYPE’ are not obfuscated.

>>> print OFX.ofx_repr()
>>> print OFX.obfuscated_ofx_repr()
>>> print OFX.xml_repr()
OFX Headers

OFX Headers are available as a dict.

Headers can be parsed in two ways:

  • if the parse() has been called, they can be retrieved using attribute OFX_headers of the parser object.
  • OFXParser can de asked to parse only the headers (not the content) with the parse_headers() method (Cf. tests 7,8 and 9 of for an example).

Package description

This package contains :

  • edofx/ ; the framework
  • tests ; contains Python unit-test classes
    • ; an example demonstrating how to parse an OFX source into specific classes.

The framework by itself is structured in 3 classes:

  • OFXNode
  • OFXParser
  • OFXObfuscator

Use python help for method level description. (Even if I’m slightly optimistic about the python help content quality…)


OFXNode is used to store parsed OFX sources.


OFXParser builds OFXNode tree from a string containing some OFX content.


OFXObfuscator is a naive obfuscator based on lexical analysis. OFXObfuscator is able to obfuscate OFX sources OFXParser has been unable to parse. Use this if you want to sent me some OFX files that OFXParser fails to process.


There you will find 3 examples and some unittests:

  • (see below)
  • ; shows how to export andofx file to csv in
  • ; shows how to generate a single account OFX file from a multi account one
  • unit tests

This file shows how to parse a multi account type / multi account OFX file into Statement and StatementTransaction classes and export everything into a set of per account csv files.

Most interesting part is the render_as_DOT() function.

Following render_as_DOT() code snippet shows how OFXNode makes it easy to load OFX content into arbitrary python objects:

    # For each account statement...
        stmt = Statement('CHECKING')
        stmt.currency   = aSTMTTRNRS.STMTRS.CURDEF.val
        stmt.bank_id    = aSTMTTRNRS.STMTRS.BANKACCTFROM.BANKID.val
        stmt.account_id = aSTMTTRNRS.STMTRS.BANKACCTFROM.ACCTID.val
        stmt.start_date = aSTMTTRNRS.STMTRS.BANKTRANLIST.DTSTART.val # returned as date
        stmt.end_date   = aSTMTTRNRS.STMTRS.BANKTRANLIST.DTEND.val   # returned as date
        # for each transaction in statement
            st          = StatementTransaction()
            st.fitid    = s.FITID.val
            st.type     = s.TRNTYPE.val
       = s.DTPOSTED.val # returned as date
            st.amount   = s.TRNAMT.val   # returned as float
       = s.NAME.val
            st.memo     = s.MEMO.val

        stmt.balance      = aSTMTTRNRS.STMTRS.LEDGERBAL.BALAMT.val # returned as float
        stmt.balance_date = aSTMTTRNRS.STMTRS.LEDGERBAL.DTASOF.val # returned as date

Shows how to export an edofx file to csv format.

Takes a multi account OFX file and generates:

  • a single account OFX file
  • an XML representation of the single OFX file
  • Parser tests (
  • OFXTree export tests (
  • Obfuscation tests (

Directory tests/fixtures contains a set of OFX file.real_file.ofx and multi_account_file.ofx have been built from real files using OFXNode.obfuscated_ofx_repr()

Disclaimer: EDOFX was my very first python code !! So many things I would have not written like this today.


  • Cyril MORISSE

Change history

0.3.8 -> 0.3.9

On 22/03/2017:

  • Fix import of formatted OFX files (ie. with indented tags)

0.3.6 -> 0.3.8

On 06/11/2015:

  • Improve PEP8 Compliance
  • Manage file encoding based on OFX Header content
  • Fix problem with file names in uppercase (eg. README.rst)


  • Port from mercurial to git.
  • Move from bitbucket to github.
  • Publish on Pypi.
  • Rework some code (4 years after)
  • Pypi and classifiers setup

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for inouk.edofx, version 0.3.9
Filename, size File type Python version Upload date Hashes
Filename, size inouk.edofx-0.3.9.tar.gz (13.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page