Created
August 31, 2017 01:51
-
-
Save judges119/470ac61bf8e20a8cd46ed25568316de3 to your computer and use it in GitHub Desktop.
Split JSON object file by key
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
import json | |
with open('file.json') as data_file: | |
data = json.load(data_file) | |
for key in data: | |
f = open(''.join([key, '.json']), 'w') | |
d = {key:data[key]} | |
f.write(json.dumps(d)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment