Skip to content

Instantly share code, notes, and snippets.

@badmofo
Created January 3, 2019 05:27
Show Gist options
  • Save badmofo/527300a3d504401546f77f51f98d19b8 to your computer and use it in GitHub Desktop.
Save badmofo/527300a3d504401546f77f51f98d19b8 to your computer and use it in GitHub Desktop.
from ofxparse import OfxParser
import sys
import csv
with open(sys.argv[1]) as f:
ofx = OfxParser.parse(f)
account = ofx.account
statement = account.statement
institution = account.institution
fields = ['institution', 'account_id', 'amount', 'checknum', 'date', 'id', 'mcc', 'memo', 'payee', 'sic', 'type']
rows = [['institution', 'account_id', 'id', 'date', 'amount', 'type', 'payee', 'memo', 'checknum']]
for tx in statement.transactions:
row = [
institution.organization,
account.account_id,
tx.id,
str(tx.date),
tx.amount,
tx.type,
tx.payee,
tx.memo,
tx.checknum,
]
rows.append(row)
print(row)
with open(sys.argv[2], 'w') as f:
w = csv.writer(f)
w.writerows(rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment