Sort and concatenation based on a group of data
Posted: Mon Apr 24, 2017 1:47 am
Hi,
I have an input file as shown below:
001 ABC AA
001 ABC BB
001 ABC CC
001 MNP 11
001 MNP 22
001 MNP AA
001 MNP BB
001 MNP CC
001 MNP DD
001 XYZ 33
I need the output to be grouped based on the first 2 columns and concatenate the 3rd column with commas, as shown in the below format:
001 ABC AA,BB,CC
001 MNP 11,22,AA,BB,CC,DD
001 XYZ 33
Can someone please help with the code for the above sort logic? Thank you!!
I have an input file as shown below:
001 ABC AA
001 ABC BB
001 ABC CC
001 MNP 11
001 MNP 22
001 MNP AA
001 MNP BB
001 MNP CC
001 MNP DD
001 XYZ 33
I need the output to be grouped based on the first 2 columns and concatenate the 3rd column with commas, as shown in the below format:
001 ABC AA,BB,CC
001 MNP 11,22,AA,BB,CC,DD
001 XYZ 33
Can someone please help with the code for the above sort logic? Thank you!!