#! /usr/bin/awk -f # # # reformats a list of numbers for xloggraph # BEGIN { if (!start) start = 1; if (!stop) stop = 1000; if (col) start=stop=col; maxcol=0; maxnumber=0; } { for(col=start; (col<=NF)&&(col <= stop); ++col) { if(($0 ~ /[a-zA-Z]/) && NR==1) { label[col] = $col } else { # count number of items in this column ++number[col]; # store them in memory line[col, number[col]] = $col; # compute the average sum[col] += $col; # compute printout size f = index($col+0,".") b = 0 if(index($col+0,".")) b = length($col+0) - f if(b > D[col]) D[col] = b if(f+D[col] > W[col]) W[col] = f+D[col] } } } END{ # find number of columns for(col in sum) { if(maxcol+0 < col+0) maxcol = col; if(maxnumber+0 < number[col]+0) maxnumber = number[col]; } for(col=start; col <= maxcol; ++col) { # W[col] = length(sum[col]) # if(W[col] < 8) W[col] = 8 # if(index(sum[col],".")) D[col] = W[col]-index(sum[col],".") avg[col] = sum[col]/number[col] sum[col] = 0; for (i = 1; i <= number[col]; ++i) { dev[col, i] = line[col, i] - avg[col]; sum[col] += dev[col, i]*dev[col, i]; } rms[col] = sqrt(sum[col]/number[col]); print avg[col] " +/- " rms[col]; print W[col], D[col]; } if(1) { # print out as xloggraph file print ""; print " $TABLE : " FILENAME " Plots:" printf " $GRAPHS:Values by line:A:1" for(col=start; col <=maxcol; ++col) { printf ", "col-start+2 } print ":" printf ":Values vs. 1st column:A:2" for(col=start; col