Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python3
# jsonline to csv converter for Andy
import csv
import json
import sys
if len(sys.argv) < 2:
print("Use {} <file.jsonline>".format(sys.argv[0]))
sys.exit(1)
writer = None
with open(sys.argv[1]) as fh:
for line in fh:
blob = json.loads(line.strip())
if not writer:
writer = csv.DictWriter(sys.stdout, fieldnames=blob.keys())
writer.writeheader()
writer.writerow(blob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.