forked from eirikmun/xwing-data2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelim.py
More file actions
32 lines (24 loc) · 998 Bytes
/
elim.py
File metadata and controls
32 lines (24 loc) · 998 Bytes
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
26
27
28
29
30
31
32
import json
import os
# Set this to your pilots folder
PILOT_DIR = r"C:\Users\gregk\Documents\GitHub\xwa-points\xwing-data2\data\pilots"
# Loop through all JSON files in all faction folders
for faction in os.listdir(PILOT_DIR):
faction_dir = os.path.join(PILOT_DIR, faction)
if not os.path.isdir(faction_dir):
continue
for filename in os.listdir(faction_dir):
if not filename.endswith(".json"):
continue
filepath = os.path.join(faction_dir, filename)
with open(filepath, "r", encoding="utf-8") as f:
ship_data = json.load(f)
changed = False
for pilot in ship_data.get("pilots", []):
if "caption" in pilot and pilot["caption"] == "":
del pilot["caption"]
changed = True
if changed:
with open(filepath, "w", encoding="utf-8") as f:
json.dump(ship_data, f, indent=2, ensure_ascii=False)
print(f"Cleaned: {filepath}")