Created
September 21, 2015 16:34
-
-
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
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
| #!/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