Skip to content

Instantly share code, notes, and snippets.

@judges119
Created August 31, 2017 01:51
Show Gist options
  • Save judges119/470ac61bf8e20a8cd46ed25568316de3 to your computer and use it in GitHub Desktop.
Save judges119/470ac61bf8e20a8cd46ed25568316de3 to your computer and use it in GitHub Desktop.
Split JSON object file by key
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