-
|
Hi there, I want to split a big yaml file into multiple yaml files. I looked into the QA with following example: #1562 but I can not really figure it out, as I don't understand how to double loop through this file. I have following data I basically need to split the files by region and item. So in the end this example should generate 4 yaml files like region1_item1.yaml , region1_item2.yaml, region2_item1.yaml and so on.. And the content should always be a key and the values of the region map:
Any help is appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Probably way to late for you now (sorry); but for future readers: You'll need to use the So the first step is to work out how to split up the doc into the components that you want in each file, then the next step is to work out the right expression to give to '-s' to generate the filenames. First Option (easier)
Then the Second (harder) - to get the item name as a root in each child: I'll need to create a new map with that item key in each result. Because it's a new map, that maeans I can't use parent to look up the tree anymore; so we'll bake in the values of region and item name in order to be able to refer to them in the '-s' expression This will yield a file like; |
Beta Was this translation helpful? Give feedback.
Probably way to late for you now (sorry); but for future readers:
You'll need to use the
-scommand to split each result into their own file.So the first step is to work out how to split up the doc into the components that you want in each file, then the next step is to work out the right expression to give to '-s' to generate the filenames.
First Option (easier)
e.g. for the path .regions.region2.item1:
Then the
-sexpression is run against that match to generate the filename. We can use 'parent' to go up the node tre…