See here
You can run this python script in the comestibles directory - I don’t see any other issues, but maybe you will:
import os
import json
# Function to load and parse JSON files in the current directory
def load_json_files_in_directory(directory):
json_files = [f for f in os.listdir(directory) if f.endswith('.json')]
data = []
for json_file in json_files:
with open(os.path.join(directory, json_file), 'r') as file:
try:
data.append(json.load(file))
except json.JSONDecodeError:
print(f"Error decoding JSON in file: {json_file}")
return data
# Function to find all "COMESTIBLE" items without a "spoils_in" value
def find_comestibles_without_spoils_in(data):
items_without_spoils_in = []
for file_data in data:
for item in file_data:
if item.get("type") == "COMESTIBLE" and item.get("comestible_type") == "FOOD" and "spoils_in" not in item and "copy-from" not in item:
# Check if the "id" field exists in the item before accessing it
if "id" in item:
items_without_spoils_in.append(item["id"])
return items_without_spoils_in
# Set the directory to the current directory where the script is located
directory = "."
# Load all JSON data from the files in the directory
data = load_json_files_in_directory(directory)
# Find all "COMESTIBLE" items that don't have "spoils_in"
items_without_spoils_in = find_comestibles_without_spoils_in(data)
# Print the list of item "id"s without "spoils_in"
for item_id in items_without_spoils_in:
print(item_id)