pkg/yqlib/doc/operators/pivot.md
Emulates the PIVOT function supported by several popular RDBMS systems.
Given a sample.yml file of:
- - foo
- bar
- baz
- - sis
- boom
- bah
then
yq 'pivot' sample.yml
will output
- - foo
- sis
- - bar
- boom
- - baz
- bah
Missing values are "padded" to null.
Given a sample.yml file of:
- - foo
- bar
- baz
- - sis
- boom
- bah
- blah
then
yq 'pivot' sample.yml
will output
- - foo
- sis
- - bar
- boom
- - baz
- bah
- -
- blah
Given a sample.yml file of:
- foo: a
bar: b
baz: c
- foo: x
bar: y
baz: z
then
yq 'pivot' sample.yml
will output
foo:
- a
- x
bar:
- b
- y
baz:
- c
- z
Missing values are "padded" to null.
Given a sample.yml file of:
- foo: a
bar: b
baz: c
- foo: x
bar: y
baz: z
what: ever
then
yq 'pivot' sample.yml
will output
foo:
- a
- x
bar:
- b
- y
baz:
- c
- z
what:
-
- ever