freqslot.awk
Generated on Tue Dec 05 17:39:06 Eastern Standard Time 2006 from freqslot.awk
# Program: FREQSLOT.AWK
# Purpose: Parse through file with frequencies, listing meta-frequencies
# Date : 25 October 2002
# Author : Bob Jonkman <bjonkman@sobac.com>
# Copyright 2008 Bob Jonkman and/or SOBAC Microcomputer Services
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Input format: Item, frequency
# Usage : gawk -f freqslot.awk -v FIELDNUM=x inputfiles > outputfile.csv
# where FIELDNUM is the field number to be counted.
BEGIN { # FS = " "
OFS = ","
SUBSEP = ","
IGNORECASE = 1
}
NR == 1 { headerfield = $FIELDNUM ;
}
$0 == "=====" { nextfile ;
}
NR != 1 {
field = $FIELDNUM ;
total++ ;
if(!freq[field]) unique++ ;
freq[field]++ ;
}
# end of scanning
# Post-process: print headers, field values, and the freqslot array
END { print("Frequency," headerfield) ;
for (i in freq)
printf("%15i,%s", freq[i], i "\n") | "sort /R" ;
print("=====");
print(total, "Total");
print(unique, "Unique");
}
# EOF: FREQSLOT.AWK
1 files processed.