maci.yamlloadall

loads multiple yaml docs from a file

loading a file

Loads multiple yaml documents from a file, and returns the corresponding python data types.

maci.yamlloadall -> Iterator[Any]

Basic Example of loading a yaml file with multiple docs using default positional parameter

data = maci.yamlloadall('mydata.yml')

In this example, we simply load a file that contains multiple yaml documents using the yamlloadall function and pass a string of the filepath to the file as an argument to the function to load the yaml data, and assign the returned data to a variable.

The returned data will be an iterator with each item containing the individual yaml document data. Information on writing multiple YAML docs in a file: https://yaml.org/spec/1.2.2/ https://gettaurus.org/docs/YAMLTutorial/#YAML-Multi-Documents

parameters & arguments

Describes all parameter functionality and accepted data types

filename: str | Path

First and only required positional argument. Accepts strings and Path objects

Use this parameter to point to your filepath

encoding: str | None

Optional parameter. Accepts strings or None. Default = None

Use this parameter to load the data with the desired codec of the encoded data if needed. The default uses the default of python, so you don't have to use this, but you can if the data is using a specific codec.

This function uses the PyYAML framework installed as a dependency from pypi for its underlying functionality. It is only using the "safe_load_all" method to protect from untrusted input. For more information on PyYAML, visit: https://pypi.org/project/PyYAML/

Last updated