annotate transpose.awk @ 0:781ac6e7a3a1 draft

Uploaded
author dereeper
date Fri, 20 Feb 2015 10:09:18 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/gawk -f
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
2
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
3 BEGIN {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
4 max_x =0;
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
5 max_y =0;
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
6 }
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
7
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
8 {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
9 max_y++;
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
10 for( i=1; i<=NF; i++ )
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
11 {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
12 if (i>max_x) max_x=i;
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
13 A[i,max_y] = $i;
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
14 }
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
15 }
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
16
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
17 END {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
18 for ( x=1; x<=max_x; x++ )
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
19 {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
20 for ( y=1; y<=max_y; y++ )
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
21 {
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
22 if ( (x,y) in A ) printf "%s",A[x,y];
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
23 if ( y!=max_y ) printf " ";
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
24 }
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
25 printf "\n";
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
26 }
781ac6e7a3a1 Uploaded
dereeper
parents:
diff changeset
27 }