0 74 1 0 2 7 3 54 4 11 5 2 0 1513 1 1 2 70 3 874 4 435 5 133 0 447 1 022 2 18 3 275 4 129 5 25 0 782 1 1 2 59 3 364 4 282 5 76 0 684 1 1 2 10 3 361 4 271 5 41 7 human-rated projects 2 0 451 1 37 2 27 3 56 4 25 5 168 3 0 1793 1 149 2 142 3 174 4 139 5 430 4 0 196 1 9 2 2 3 16 4 0 5 96 5 0 822 1 36 2 15 3 69 4 9 5 332 6 0 169 1 12 2 3 3 24 4 3 5 77 EOF cat dat | gawk 'BEGIN { OFS = "," } NF==3 { Klass = $2 ; print } NF==1 { Phase = $1 ; print } NF==2 && ! $1 { All = $2 ; next } NF==2 { if (Klass== "human-rated") Human[Phase,$1]= int(100*$2/All) if (Klass== "robotic") Robot[Phase,$1]= int(100*$2/All) } END { for(i in Human) print i , Human[i] , Robot[i] } '