Hi all,
I have a input file like this,
Col1,Col2
a,5%
a,6%
a,7%
a,8%
I need the output as
a,5%,6%,7%,8%
Any ideas to solve this issue??
Thanks in advance,
Vertical Pivot in parallel
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Yes, vertical pivot as you identified in your subject line.
First, partition and sort your data by the key column. Use a stable sort, so that the original order of rows is preserved for each key value.
Use a Transformer stage to build lines of output containing each new value in a new field. Use stage variables to preserve the previous value of earlier fields in each row and reinstate those in the output.
Pass that result through a Remove Duplicates stage, preserving the last record of each group.
If you want a comma-delimited file, simply use a Sequential File stage with appropriate format properties set. Otherwise use another Transformer stage to assemble the multiple fields into a comma-separated list.
First, partition and sort your data by the key column. Use a stable sort, so that the original order of rows is preserved for each key value.
Use a Transformer stage to build lines of output containing each new value in a new field. Use stage variables to preserve the previous value of earlier fields in each row and reinstate those in the output.
Pass that result through a Remove Duplicates stage, preserving the last record of each group.
If you want a comma-delimited file, simply use a Sequential File stage with appropriate format properties set. Otherwise use another Transformer stage to assemble the multiple fields into a comma-separated list.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I did not mention the Pivot stage. The Pivot stage does not support vertical pivot. The PXPivot stage will, in a near future release, but does not currently do so.
I provided a solution that does not involve the Pivot stage, but shows how to accomplish vertical pivot in a parallel job, which is what you sought.
I provided a solution that does not involve the Pivot stage, but shows how to accomplish vertical pivot in a parallel job, which is what you sought.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.