Commits

Anonymous committed 9c45acc

exploring transactions and labels

  • Participants
  • Parent commits f9b2ecb

Comments (0)

Files changed (1)

File trx_explore.py

 import json
 import pprint
 
+from bunch import Bunch
+
 def explore(fp):
-    x = json.load(fp)
-    pprint.pprint(x)
+    data = json.load(fp)
+
+    trxs = [Bunch.fromDict(o) for o in data]
+    trxs.sort(key=lambda(tx): int(tx.id))
+    pprint.pprint([(tx.id, tx.date,
+                    (int(tx.amount.replace('$', '').\
+                         replace(',', '').replace('.', '')) * (
+                             -1 if tx.isDebit else 1), 100),
+                    tx.amount, tx.isDebit) for tx in trxs])
+
+    print "Labels:"
+    pprint.pprint([(tx.id, l['id'], l['name'])
+                   for tx in trxs
+                   for l in tx.labels])
+
 
 def main(argv):
     fn = argv[1]