I'm having several .json files with the same structure in the same directory. I would like to create a unique csv file with value from some keys of each json file.
Looping through one single file everything works. Here a snapshot of the script:
import json, os
import csv
input_file = open ('JSON/test.json')
json_array = json.load(input_file)
object_list = []
for obj in json_array:
    for item in obj['objects']:
        object_details = {"_system_object_id":None,"preview_url":None,"original_download_url":None,"original_url":None}
        object_details['_system_object_id'] = item['_system_object_id']
        try:
            object_details['preview_url'] = item['do']['do_digitalobject'][0]['versions']['preview']['url']
        except:
            print("not found")
        try:
            object_details['original_download_url'] = item['do']['do_digitalobject'][0]['versions']['original']['download_url']
        except:
            print("not found")
        try:
            object_details['original_url'] = item['do']['do_digitalobject'][0]['versions']['original']['url']
        except:
            print("not found")
        #object_details['type'] = item['type']
        object_list.append(object_details)
    print(object_list)
How to process all the .json files in the folder?
Thanks
 
    