Created
July 26, 2018 10:52
-
-
Save jonnyshaw89/803b9a95c48a94468ca9f10a5b45cba5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import simplejson as json | |
directory = "data/en" | |
for filename in os.listdir(directory): | |
if filename.endswith(".json"): | |
print(os.path.join(directory, filename)) | |
with open(os.path.join(directory, filename), encoding='utf8') as json_data: | |
schema_data = json.load(json_data, use_decimal=True) | |
metadata = schema_data['metadata'] | |
if isinstance(metadata, dict): | |
metadata_list = [] | |
for key in metadata.keys(): | |
metadata[key]['validator'] | |
metadata_list.append({"name": key, "validator": metadata[key]['validator']}) | |
schema_data['metadata'] = metadata_list | |
print("Writing: " + os.path.join(directory, filename)) | |
with open(os.path.join(directory, filename), "w", encoding='utf8') as file: | |
file.write(json.dumps(schema_data, sort_keys=True)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment