Created
October 18, 2018 10:03
-
-
Save philippkeller/5fe8e2111f3c73ae94fa7a86493e7f3a to your computer and use it in GitHub Desktop.
flatten json using flatten_json
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 python3 | |
import flatten_json | |
import sys | |
import json | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
print(f'usage: {sys.argv[0]} in.csv out.csv') | |
f_out = open(sys.argv[2], 'w') | |
for line in open(sys.argv[1]): | |
j2 = flatten_json.flatten_json(json.loads(line)) | |
f_out.write(json.dumps(j2)) | |
f_out.write("\n") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment