import json data = None extractedData = [] with open("airport-codes_json.json", "r") as read_file: data = json.load(read_file) for item in data: if item.iata_code != None: extractedData.append(item) with open("iata_only.json", "w") as write_file: json.dump(data, write_file)