Python Read Json File And Convert To CSV

Jan 30, 2018
import json# import csvimport unicodecsv as csvwith open('input.json') as data_file:    data = json.loads( open('output.csv', 'wb') as csv_file:    writer = csv.writer(csv_file, encoding='utf-8')    writer.writerow(['id', 'date', 'name'])    for row in data:        item_id = row['id']        created = row['created']        name = row['title']        row = [item_id, created, name]        writer.writerow(row)

NOTE: to support unicode in CSV, you need unicodecsv

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.