Skip to main content

ofxparse2 (fork of ofxparse)

ofxparse2 is a parser for Open Financial Exchange (.ofx) format files, originally based on the excellent ofxparse by Jonathan Seutter.

OFX files are available from almost any online banking website and are commonly used for downloading bank or investment statements. This fork includes enhancements focused on better compatibility with Brazilian banks, automatic encoding detection, and improved robustness for real-world OFX variations.


🚀 Fork and Enhancements

This repository is a fork of the original ofxparse project.

Bug fixes, improvements, and compatibility updates were made by Pedro Schneider (@pedrin-pedrada).

✅ What's improved?

  • Encoding detection using chardet to handle files like:

    <?xml version="1.0" encoding="utf-8" ?>
    
  • Handles malformed or partially invalid headers from certain Brazilian banks.

  • Better support for common OFX/QFX variations found in South America.

📦 Fork available at: https://github.com/pedrin-pedrada/ofxparse2


📦 How to Install

You can install ofxparse2 directly from GitHub using pip:

pip install ofxparse2

To add it to a requirements.txt:

git+https://github.com/pedrin-pedrada/ofxparse2.git

🧪 How to Use

Here’s a simple example of how to parse an .ofx file:

from ofxparse import OfxParser
import codecs

with codecs.open("example.ofx", "r", encoding="utf-8") as file:
    ofx = OfxParser.parse(file)

# Access account information
account = ofx.account
print("Account ID:", account.account_id)
print("Bank ID:", account.routing_number)
print("Branch ID:", account.branch_id)

# Access statement and transactions
statement = account.statement
print("Start Date:", statement.start_date)
print("End Date:", statement.end_date)
print("Balance:", statement.balance)

for transaction in statement.transactions:
    print(f"{transaction.date} - {transaction.amount} - {transaction.payee}")

🛠 Development

Prerequisites

# Ubuntu
sudo apt-get install python-beautifulsoup python-nose python-coverage-test-runner

# Python 3
pip install BeautifulSoup4 six lxml nose coverage

# Python 2 (legacy)
pip install BeautifulSoup six nose coverage

Running Tests

nosetests
# or
python -m unittest tests.test_parse

Coverage Report

coverage run -m unittest tests.test_parse
coverage report
coverage html
firefox htmlcov/index.html

📂 Help Wanted

If you have .ofx or .qfx files that don't work properly, feel free to contribute! Please anonymize sensitive information and submit files or issues via GitHub.


🌐 Original Homepage


📄 License

ofxparse2 is released under the MIT license. See the LICENSE file for full terms.

The core idea: if you're allowed to use Python for your project, you're also allowed to use this library.

Metadata

Release files for ofxparse2 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ofxparse2 0.2.2
File Size Uploaded
ofxparse2-0.2.2.tar.gz 34.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ofxparse2 0.2.2
File Interpreter ABI Platform
ofxparse2-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 69.9 kB

Release files / ofxparse2-0.2.2.tar.gz

Download URL ofxparse2-0.2.2.tar.gz
Size 34.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e39cc11a4b01e0cb127694d0acc0ffb1fc8f5c04d60b75dfa440ebe0fce28274
BLAKE2b-256 checksum
How to use checksums
48e5a98c0213075a21b2ee43be13a9e03ec41b795014de51f0796629ff692033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.12 Linux/6.8.0-57-generic

Release files / ofxparse2-0.2.2-py3-none-any.whl

Download URL ofxparse2-0.2.2-py3-none-any.whl
Size 35.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a0e85135b136be0566163bfce6afcc305f667311d9a58c9bb00774d15b254ed
BLAKE2b-256 checksum
How to use checksums
9ff0bfa878f9401424f677e257dbd395786c1a9159ba5b93fca20c8ae1231473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.2 CPython/3.10.12 Linux/6.8.0-57-generic

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page