I don't find an easy way to do this..
I have a large complex yaml file, I want to load it and write only a couple of the keys into a NEW yaml file.
So for example:
Existing:
a:
bsect:
thing: one
ab:
bbsect:
morething: more
thisone: dbname
ac:
ccc:
cccthing: here
bd:
bbb:
bbbthing: again
So I load the yaml file using import yaml and I load using: cfg = yaml.load(file) within a with open.
I want to create a NEW yaml file just with with cfg[ab] and cfg[thisone]
But when I create the yaml file using yaml.dump I obviously end up with the content of cfg[ab] and cfg[thisone] without the keys and it looks like this.
bbsect:
morething: more
dbname.
It makes sense but what is the best way to end up with a new yaml file that contains:
ab:
bbsect:
morething: more
thisone: dbname
I hope this makes sense.
Thanks in advance.