Created
January 3, 2019 05:27
-
-
Save badmofo/527300a3d504401546f77f51f98d19b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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