Skip to main content

## squash

The squash command allows you to reduce multiple rows with the same key field values to a single row, accumulating values of numeric fields as it does so.

See also: unique

Flag | Req'd? | Description
-f fields | Yes | Comma-separated list specifying the key fields. All CSV records with the same key will be squashed into a single record on output.
-n fields | Yes | Comma-separated list specifying numeric fields which will be accumulated by addition and output together with the matching key fields. Numeric fields are assumed to be integer values by default.
-rn | No | Specifies that the the fields described by the -n option should be treated as real numbers.
-nn value | No | Specifies a numeric value that should be used when any of the fields specified with the -n option does not contain a numeric value. If this option is not used, encountering such a non-numeric value is a fatal error.

The following example squashes the rows in sales_region.csv using the first field as the key:

csvfix.exe squash -f 1 -n 2 data/sales_region.csv

producing:

"East","200"

"North","2793"

"South","1118"

"West","77"

Created with the Personal Edition of HelpNDoc: iPhone web sites made easy

####