Skip to content

Instantly share code, notes, and snippets.

@cmattoon
Created December 5, 2016 20:03
Show Gist options
  • Save cmattoon/4fadd94f78e817214558802a5fe87224 to your computer and use it in GitHub Desktop.
Save cmattoon/4fadd94f78e817214558802a5fe87224 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
Convert argv[1] from list (array) to dict (object)
"""
import sys, json
OUTFILE = 'test-output.json'
with open(sys.argv[1]) as fd:
data = json.loads(fd.read())
new = {}
for obj in data:
new[ obj['url'] ] = {
'type': obj['type'],
'language': obj['language'],
'notes': obj['notes']
}
with open(OUTFILE, 'wb') as fd:
json.dump(new, fd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment