![]() |
![]()
| ![]() |
![]()
NAMEtotal - total and subtotal numeric columns in a text file according to field keys SYNOPSIStotal [-Ndv] <key-cols> <data-columns> <file> DESCRIPTIONtotal reads a text file of columnar data in text and numeric format. By default, columns are separated by one or more whitespace characters. The -F option allows on to choose a separation character. In this case exactly one separation character lies between columns. total forms data keys from combinations of text and numeric columns. and for each key value it can summarize numeric columns, either by average, sum, minimum or maximum. After reading the file it prints a summary of each key combination found in the file along with the summarized data. Optionally, you can summarize entire columns without regard to key values. OUTPUTtotal prints one line of output for each key combination. Each line contains 0 or more key fields, and 1 or more summarization fields (if there are 0 keys, then all records are summarized together - they are not broken down by key). EXAMPLEConsider the following data file where the five columns represent city, state, month, precipitation and average temp.
suppose we want the average temperature for these three cities over Jan, Feb, Mar. The command would be this,
total uses columns 1 and 2 as data keys. Then for each unique combination of city (column 1) and state (column 2) it takes the average temperature. The output looks like this (note that output is sorted by key)
If we want total precipitation for each city,
and the output is
If we want average temperature across each state we could try
and get
Finally, if we want the maximum temperature for the entire file we could do
and get
KEY COLUMNSThe first parameter specifies the key columns. This is a comma delimited list of columns numbers with no whitespace. The columns are numbered starting at column 1. In the first example above we used columns 1 and 2 (city and state) for our keys. There is also a special value '-' which tells total not to separate values into keys, but to summarize the entire file. DATA COLUMNSThe second parameter specifies data columns and the action on the data column. This is a comma delimited list with no white space. Each data column specification consists of a column number and an optional command in the form of a single letter. The default command is to sun the column. The letter commands perform the following operations on the column.
OUTPUT COLUMNSFor every key column and data column total produce an output column. The order in which the columns are written is the same as the order in which the key columns, and then data columns are specified on the command line. For example, if you use the command
the output file will have 6 columns, the first output column is carried from column 3 of the input file, the second output column is carried from column 1 of the input file, the third output column from column 5 of the input file, and so on. OPTIONS
BUGSReport any to jon.rifkin@uconn.edu. AUTHORj rifkin <jon.rifkin@uconn.edu>
VERSION1.0 Oct 13, 2005
|