Skip to content

Instantly share code, notes, and snippets.

@almet almet/kinto2csv.py
Last active Dec 15, 2016

Embed
What would you like to do?
# -*- coding: utf-8 -*-
import unicodecsv as csv
import sys
import json
def json_to_csv(source, destination):
loaded_json = json.load(source)['data']
writer = csv.writer(destination)
# First row contains the titles
keys = loaded_json[0].keys()
writer.writerow(keys)
for item in loaded_json:
values = [item[k] for k in keys]
writer.writerow(values)
if __name__ == '__main__':
json_to_csv(sys.stdin, sys.stdout)
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.