Created
March 10, 2015 13:43
-
-
Save KrazyADM/cbeeb98d08c9247c58b2 to your computer and use it in GitHub Desktop.
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
import fileinput | |
import json | |
import csv | |
import sys | |
l = [] | |
for line in fileinput.input(): | |
l.append(line) | |
myjson = json.loads(''.join(l)) | |
keys = {} | |
for i in myjson: | |
for k in i.keys(): | |
keys[k] = 1 | |
mycsv = csv.DictWriter(sys.stdout, fieldnames=keys.keys(), | |
quoting=csv.QUOTE_MINIMAL) | |
mycsv.writeheader() | |
for row in myjson: | |
mycsv.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment