newtphys_dl3dv / utils /convert_transform.py
sebo_the_tramp
cleanup
77dc6ce
Raw History Blame Contribute Delete
972 Bytes
import yaml
import json
def read_yaml(file_path):
with open(file_path, 'r') as file:
data = yaml.safe_load(file)
return data
def read_json(file_path):
with open(file_path, 'r') as file:
data = json.load(file)
return data
def write_json(file_path, data):
with open(file_path, 'w') as file:
json.dump(data, file, indent=4)
if __name__ == "__main__":
# Example usage
yaml_data = read_yaml('transforms.yaml')
# print("YAML Data:", yaml_data['scene129'])
json_data = read_json('used_scenes.json')
print("JSON Data:", json_data)
for data in json_data:
print(data['name'])
if data['name'].replace('_', '') in yaml_data:
print(yaml_data[data['name'].replace('_', '')])
data['transforms'] = yaml_data[data['name'].replace('_', '')]['transform']
print("All data processed.")
write_json('output.json', json_data)
print("Data written to output.json")