split one column into multiple columns

hey,

i have the following data:
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
4.600000
9.800000
12.70000
12.90000
33.80000

The following command , awk '{a[NR%14+1]=a[NR%14+1]" "$0} END {for (i in a){print a[i]}}', yields:

0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 4.600000
0.000000 0.000000 9.800000
0.000000 0.000000 12.70000
0.000000 0.000000 33.80000
0.000000 0.000000 12.90000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000

where i want the last column to be

0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
4.600000
9.800000
12.70000
12.90000
33.80000. The ascending order is lost...

Can anyone help?

Thanx:)

nawk '
   {idx=FNR%14+1} 
   !(idx in a){key[++key[0]]=idx}
   {a[idx]=a[idx] OFS $0} 
    END {for(i=1;i<=key[0];i++) print a[key]}' myFile

nice, that worked perfectly...
Thanx alot

you probably need to this tweak if to be a bit more pedantic:

nawk '
   {idx=FNR%14+1} 
   !(idx in a){key[++key[0]]=idx}
   {a[idx]=(idx in a) ? a[idx] OFS $0 : $0} 
    END {for(i=1;i<=key[0];i++) print a[key]}' myFile

cool, I'll use it and see what it does differently under different situations...
not quite sure what you did, but it works... hehe.
Can make out some of the code, but need to check out the rest unless you can explain it better to me...
Thanx alot

The above assumes that the input 'stream' has already been sorted in the desired output order.

nawk -v col="$1" '{_[NR]=$0;lines=NR}
END{
tmp=lines/col
for(i=1;i<=tmp;i++)
{
for(j=1;j<=col;j++)
printf("%s ",_[i+(j-1)*col])
print ""
}
}' yourfile

Thank you :slight_smile: