32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import os
|
|
import json
|
|
|
|
|
|
def process_json_files(directory):
|
|
for filename in os.listdir(directory):
|
|
if filename.endswith('.json') and ("_mod.json" not in filename):
|
|
filepath = os.path.join(directory, filename)
|
|
|
|
with open(filepath, 'r') as f:
|
|
try:
|
|
data = json.load(f)
|
|
except json.JSONDecodeError:
|
|
continue
|
|
|
|
def remove_available_markets(obj):
|
|
if isinstance(obj, dict):
|
|
return {key: remove_available_markets(value) for key, value in obj.items() if key != 'available_markets'}
|
|
elif isinstance(obj, list):
|
|
return [remove_available_markets(item) for item in obj]
|
|
else:
|
|
return obj
|
|
|
|
modified_data = remove_available_markets(data)
|
|
|
|
modified_filepath = os.path.join(directory, f"{os.path.splitext(filename)[0]}_mod.json")
|
|
with open(modified_filepath, 'w') as f:
|
|
json.dump(modified_data, f, indent=4)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
process_json_files("prefetched")
|