skip to Main Content

I am trying to pull ‘created’ from the Monzo data I’m pulling.

I have made a call to the Monzo api with the following code:

from monzo.monzo import Monzo

client = Monzo(INSERT API KEY)
data = client.get_transactions("INSERT ACCOUNT NUMBER")

print (data)

and I can’t quite get the data I need which looks like this:

d': 'merch_000094MPASVBf7xCdrZOz3', 'created': '2016-01-20T21: 26: 33.985Z', 'name': 'DelicedeFrance', 'logo': 'https: //mondo-logo-cache.appspot.com/twitter/deliceuk/?size=large', 'emoji': '🇫🇷', 'category': 'eating_out', 'online': False, 'atm': False, 'address': {'short_formatted': 'LiverpoolStreetStation,
LondonEC2M7PY', 'formatted': 'LiverpoolStreetStation,
LondonEC2M7PY,
UnitedKingdom', 'address': 'LiverpoolStreetStation', 'city': 'London', 'region': 'GreaterLondon', 'country': 'GBR', 'postcode': 'EC2M7PY', 'latitude': 51.518159172221615, 'longitude': -0.08210659649555102, 'zoom_level': 17, 'approximate': False}, 'updated': '2016-02-02T14: 10: 48.664Z', 'metadata': {'foursquare_category': 'Restaurant', 'foursquare_category_icon': 'https: //ss3.4sqi.net/img/categories_v2/food/default_88.png','foursquare_website': '', 'google_places_icon': 'https: //maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png', 'google_places_name': 'DelicedeFrance', 'suggested_name': 'DelicedeFrance', 'suggested_tags': '#food', 'twitter_id': ''}, 'disable_feedback': False}, 'notes': '', 'metadata': {}, 'account_balance': 3112, 'attachments': [], 'category': 'eating_out', 'is_load': False, 'settled': '2017-04-28T04: 54: 18.167Z', 'local_amount': -199, 'local_currency': 'GBP', 'updated': '2017-04-28T06: 15: 06.095Z',  'counterparty': {}, 'originator': False, 'include_in_spending': True}, {'created': '2017-04-28T08: 54: 10.917Z','amount': -130, 'currency': 'GBP', 'merchant': {'created': '2016-04-21T08: 02: 13.537Z','logo': 'https: //mondo-logo-cache.appspot.com/twitter/MCSaatchiLondon/?size=large', 'emoji': '🍲', 'category': 'eating_out', 'online': False, 'atm': False...

How do I pull the ‘created’ date?

2

Answers


  1. If this is actually right json code and you just have paste errors, than you can use the python libary json:

    import json
    data = json.loads(datastring)
    

    If this not json code, you probably have to write a parser on your own.

    Login or Signup to reply.
  2. Try this:

    #!/usr/bin/env python
    import csv
    
    from pymonzo import MonzoAPI
    
    
    if __name__ == '__main__':
        monzo_api = MonzoAPI()
        monzo_transactions = monzo_api.transactions()
    
        with open('monzo_transactions.csv', 'w') as csvfile:
            writer = csv.writer(csvfile)
    
            for transaction in monzo_transactions:
                writer.writerow([
                    transaction.amount, transaction.description, 
    transaction.created,
                ])
    
        print('All done!')
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search