Created
November 23, 2015 04:50
-
-
Save auxiliary-character/b02399fc779ffdde5555 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 json | |
import csv | |
import sys | |
def main(): | |
if len(sys.argv) < 3: | |
print("Usage: " + sys.argv[0] +"input.json output.csv") | |
else: | |
with open(sys.argv[1]) as jsonfile: | |
with open(sys.argv[2], "w") as csvfile: | |
writer = csv.writer(csvfile) | |
data = json.load(jsonfile) | |
for entry in data: | |
line = [entry["main"]] | |
line.extend(entry["alts"]) | |
writer.writerow(line) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment