forked from ghost-land/NX-DB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.py
25 lines (20 loc) · 793 Bytes
/
merge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import json
import os
# Directories to traverse
directories = ['base', 'dlc', 'update', 'retro']
# Dictionary to store the combined data
combined_data = {"titledb": {}}
# Traverse each directory
for directory in directories:
for root, _, files in os.walk(directory):
for filename in files:
if filename.endswith(".json"):
filepath = os.path.join(root, filename)
with open(filepath, 'r') as f:
game_data = json.load(f)
game_id = game_data["id"]
combined_data["titledb"][game_id] = game_data
# Write the combined data to fulldb.json
with open('fulldb.json', 'w') as outfile:
json.dump(combined_data, outfile, indent=4)
print("fulldb.json has been created successfully.")