I have used the yq command to format a yaml file:
cat includelist.yml |yq -r '.ProductLine.ADO_FeedsList'
output:
---
ProductLine:
ProductLineName: AAAAA
ADO_FeedsList:
- ProjectName: IT
FeedsName:
- test
- test2
- ProjectName: organization
FeedsName:
- hello
- world
---
ProductLine:
ProductLineName: BBBBB
ADO_FeedsList:
- ProjectName: Fin
FeedsName:
- good
- aaaa
- ProjectName: organization
FeedsName:
- bbb
- ccc
Could somebody give me some suggestion,I don't known how to convert to csv format.
My question: how to convert the content to the following format:
IT,test
IT,test2
orginazation,hello
orginazation,world
Fin,good
Fin,aaaa
organization,bbb
organization,ccc
Thanks a ton.🙂
If you are using mikefarah/yq anyway, you could directly output CSV using -o csv (instead of using -o json and calling jq):
yq -o csv '.ProductLine.ADO_FeedsList[] | [.ProjectName] + (.FeedsName[] | [.])' includelist.yml
IT,test
IT,test2
organization,hello
organization,world
Fin,good
Fin,aaaa
organization,bbb
organization,ccc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With