Last active
July 17, 2023 15:10
-
-
Save aarong1/ab905dda8dce3367adfd3bfd0a50ad53 to your computer and use it in GitHub Desktop.
load a yaml file. A human readable file type usually used for configurations
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 yaml | |
yaml.load(open(<path_to_yaml_config>, 'r'), Loader=yaml.SafeLoader) | |
# convert json to yaml and back again. | |
import json | |
with open('config.json', 'r') as file: | |
configuration = json.load(file) | |
with open('config.yaml', 'w') as yaml_file: | |
yaml.dump(configuration, yaml_file) | |
with open('config.yaml', 'r') as yaml_file: | |
print(yaml_file.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment