Skip to content

Instantly share code, notes, and snippets.

@auxiliary-character
Created November 23, 2015 04:50
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 auxiliary-character/b02399fc779ffdde5555 to your computer and use it in GitHub Desktop.
Save auxiliary-character/b02399fc779ffdde5555 to your computer and use it in GitHub Desktop.
#!/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