Search code examples
ruamel.yaml

Does ruamel.yaml have a function to do the process with all files in one directory?


Does ruamel.yaml have a function to do the process with all files in one directory? Something like this: data = yaml.load(Path("*.*"))


Solution

  • No, it does not, but you can do it one line (assuming you have the imports and the YAML() instance):

    from pathlib import Path
    import ruamel.yaml
    
    yaml = ruamel.yaml.YAML()
    
    data = [yaml.load(p) for p in Path('.').glob('*.yaml')]