Skip to content

Instantly share code, notes, and snippets.

@mtholder
Created September 21, 2015 16:34
Show Gist options
  • Select an option

  • Save mtholder/d4736125eaf93f3c3e42 to your computer and use it in GitHub Desktop.

Select an option

Save mtholder/d4736125eaf93f3c3e42 to your computer and use it in GitHub Desktop.
after filling a directory from running a lot of curl calls generated by https://gist.github.com/mtholder/ddae56851edd81180767 run this giving it the path to the dir and an output filename
#!/usr/bin/env python
import sys
import os
import json
import codecs
dn = sys.argv[1]
outfn = sys.argv[2]
d = {}
for s in os.listdir(dn):
if s.endswith('.out'):
key = s[:-4]
fp = os.path.join(dn, s)
print fp
x = json.loads(codecs.open(fp, 'rU', encoding='utf-8').read())
d[key] = x
with codecs.open(outfn, 'w', encoding='utf-8') as o:
json.dump(d, o, indent=1, separators=(',', ': '), sort_keys=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment