-
-
Save andrix/3cc3ddef4044154fa0f2 to your computer and use it in GitHub Desktop.
This file contains 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, json | |
import codecs | |
import gzip | |
out = codecs.getwriter('utf8')(sys.stdout) | |
def _get_input(): | |
if len(sys.argv) <= 1: | |
return sys.stdin | |
fname = sys.argv[1] | |
f = open(fname) | |
if fname.endswith(".gz"): | |
return gzip.GzipFile(fileobj=f) | |
return f | |
for l in _get_input(): | |
out.write(json.dumps(json.loads(l), indent=3, ensure_ascii=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment