From anonymous, 4 Months ago, written in Python.
Embed
  1. import sys
  2. import json
  3.  
  4. for filename in sys.argv[1:]:
  5.     with open(filename, 'r') as f:
  6.         data = json.load(f)
  7.  
  8.     amounts = []
  9.     for sponsor in data:
  10.         for transaction in sponsor['transactions']:
  11.             status = transaction['status']
  12.             if status != 'settled':
  13.                 assert status == 'processor_declined'
  14.                 continue
  15.             raw_amount = transaction['processed_amount']
  16.             assert raw_amount[0] == '$'
  17.             assert raw_amount.endswith('.00')
  18.             amount = int(raw_amount[1:-3])
  19.             amounts.append(amount)
  20.  
  21.     month = filename.split('-')[-2]
  22.     print(f'{month:10} USD {sum(amounts)}')
  23.