Skip to content

Instantly share code, notes, and snippets.

@aarong1
Last active July 17, 2023 15:10
Show Gist options
  • Save aarong1/ab905dda8dce3367adfd3bfd0a50ad53 to your computer and use it in GitHub Desktop.
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
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