A parser for OFX files with improved encoding detection and compatibility with malformed headers
Project description
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
chardetto 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
- Homepage: https://sites.google.com/site/ofxparse
- Source: https://github.com/jseutter/ofxparse
📄 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.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ofxparse2-0.2.2.tar.gz.
File metadata
- Download URL: ofxparse2-0.2.2.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e39cc11a4b01e0cb127694d0acc0ffb1fc8f5c04d60b75dfa440ebe0fce28274
|
|
| MD5 |
726cbf0bfab697ae374eaaf10e1d95b4
|
|
| BLAKE2b-256 |
48e5a98c0213075a21b2ee43be13a9e03ec41b795014de51f0796629ff692033
|
File details
Details for the file ofxparse2-0.2.2-py3-none-any.whl.
File metadata
- Download URL: ofxparse2-0.2.2-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a0e85135b136be0566163bfce6afcc305f667311d9a58c9bb00774d15b254ed
|
|
| MD5 |
8157b99efd13751190182100ccffb3b5
|
|
| BLAKE2b-256 |
9ff0bfa878f9401424f677e257dbd395786c1a9159ba5b93fca20c8ae1231473
|