0

am new to Python and need to parse the date and '4. close' from the following JSON. Would be very grateful for pointers how to do this the pythonic way.

{'2017-01-24': {'1. open': '207.8600',
                 '2. high': '209.4000',
                 '3. low': '207.7479',
                 '4. close': '208.9700',
                 '5. adjusted close': '208.0046',
                 '6. volume': '1940125',
                 '7. dividend amount': '0.00',
                 '8. split coefficient': '1.0000'},...

1 Answer 1

1

You can parse JSON like this:

import json
from pprint import pprint

with open('path_of_file.json') as data_file:    
    data = json.load(data_file)

pprint(data)
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Moshe. Thats what i figured already actually. But whats the best way to slice it in order to get the date at the beginning and the value for '4. close' so i can stick them into a CSV or a database?
Actually so easy. Sorry to bother you guys. the output is already a Python dictionary and the date is simply the key.
Yeah sorry, JSON is nearly universal as most programming languages have value key pairs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.