Created
March 27, 2012 00:34
-
-
Save anonymous/2211032 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #!/bin awk -f BEGIN { FS="," rows[""]=0 rowsc[""]=0 labels[""]=0 } { if (NR == 1) { header=$0; cols=NF; } else if ($0 != header) { labels[$1]++ for (i=2; i<=NF; i++) { rows[$1 " " i] += $i rowsc[$1 " " i]++ } } } END { print header for (label in labels) { if (label == "") continue line=label for (i=2; i<=cols; i++) { if (rowsc[label " " i]) { avg=rows[label " " i]/rowsc[label " " i] line=sprintf("%s,%8.4f", line, avg) } } print line } }