Categories
tech

Unbxd JSON Feed to CSV Python Script

import json, os, csv
def create_list_from_json(jsonfile):
    with open(jsonfile) as f:
        data = json.load(f)
    
    data_list = []
​
    for item in data['feed']['catalog']['add']['items']:
        data_list.append(item)
​
    return data_list
​
def write_csv():
​
    item_list = create_list_from_json(f'json/data.json')
    for item in item_list:
        with open('johnrules.csv', 'a') as c:
            writer = csv.writer(c)
            writer.writerow(item.values())
        c.close()
​
if __name__== '__main__':
    write_csv()

Leave a Reply

Your email address will not be published. Required fields are marked *