How to split one long column into multiple rows with 3 each ?

I have a large csv dataset like this :

A	value1
A	value2
A	value3
B	value1
B	value2
B	value3
C	value1
C	value2
C	value3

what I expected output is :

A	value1	value2	value3
B	value1	value2	value3
C	value1	value2	value3

I'm thinking of use like awk, columns , but haven't find a proper way to do that.
could anyone give me some clues?

Try

awk 'LAST != $1 {printf "%s%s", DL, $0; LAST = $1; DL = RS; next}; {printf "\t%s", $2} END {printf RS}' file
A    value1    value2    value3
B    value1    value2    value3
C    value1    value2    value3
1 Like

Thank you RudiC . That's a cool solution, which is also suitable for more complex situations.

Nice solution :cool:
For symmetry reason (and the border case "empty input file") it should be END {printf DL} .

1 Like

Hi.

I've often wondered why there hasn't been a utility (or mode in join ) to do this kind of operation -- a self-join, as it were ... cheers, drl