I have a table test.csv
with column
X
1
1
1
2
2
5
5
5
5
I want to compare each element in column X
with 1 (in this case I have 3 matches)
I want to count the number and print output in a new file output.txt as follows
[c1]
1 2 3
Next each X
column element with 2 (here 2 matches)
Want to append the result to output.txt
[c1]
1 2 3
[c2]
4 5
Next each element in column X
with 5 (4 matches are there)
So final output.txt is
[c1]
1 2 3
[c2]
4 5
[c3]
6 7 8 9
My current table contains 750 elements in a column. I want to create an output as I state in the above example. Can I use for loop or multiple conditional loop?