Skip to content

Instantly share code, notes, and snippets.

@philippkeller
Created October 18, 2018 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippkeller/5fe8e2111f3c73ae94fa7a86493e7f3a to your computer and use it in GitHub Desktop.
Save philippkeller/5fe8e2111f3c73ae94fa7a86493e7f3a to your computer and use it in GitHub Desktop.
flatten json using flatten_json
#!/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