-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfilter.py
More file actions
36 lines (31 loc) · 1.23 KB
/
filter.py
File metadata and controls
36 lines (31 loc) · 1.23 KB
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
33
34
35
36
"Filter data needed for automatch script"
import json
# Define source and target file paths
SOURCE_FILE = "ocl_source_snapshots/MSF_Source_20240717_220327.json"
FILTERED_FILE = f"{SOURCE_FILE.split('.', maxsplit=1)[0]}_Filtered.json"
# Load the JSON file
with open(SOURCE_FILE, "r", encoding="utf-8") as file:
data = json.load(file)
# Extract the required fields
filtered_data = []
for concept in data:
filtered_concept = {
"uuid": concept.get("uuid"),
"id": concept.get("id"),
"external_id": concept.get("external_id"),
"display_name": concept.get("display_name"),
"datatype": concept.get("datatype"),
"concept_class": concept.get("concept_class"),
"display_locale": concept.get("display_locale"),
"URL": concept.get("url"),
"organization": concept.get("organization"),
"source": concept.get("source"),
"owner": concept.get("owner"),
"extras": concept.get("extras"),
"names": concept.get("names"),
"descriptions": concept.get("descriptions"),
}
filtered_data.append(filtered_concept)
# Save the filtered data to a new JSON file
with open(FILTERED_FILE, "w", encoding="utf-8") as file:
json.dump(filtered_data, file, indent=4)