The sort command sorts CSV input data on one or more fields. You can specify ascending and descending order, and use alphabetic or numeric comparisons. In order to perform a sort, CSVfix currently reads all data into memory prior to sorting - you should therefore be cautious about using this command on very large data files.
See also: shuffle
Flag |
Req'd? |
Description |
|
-f fields |
No |
Specifies a comma-separated list of fields to sort on. If not specified, the data is sorted on the first field only. For example, -f 4,1 specifies that the data should be sorted using field 4 , and within that field on field 1:. A or D - specifies Ascending (the default) or Descending order
As an example, 1:AN means sort the first input field numerically in ascending order. The difference between the numeric and string sorting can be seen by considering the following data |
|
-rh |
No |
Treat the first input record as a CSV header containing the column names and do not sort it, but place it as the first record in the sorted output. |
The following example sorts the names.csv file into descending order of sex and ascending order of surname:
csvfix.exe sort -f 3:D,2 data/names.csv
which produces:
"Charles","Dickens","M"
"Herman","Melville","M"
"Flann","O'Brien","M"
"Oscar","Wilde","M"
"Jane","Austen","F"
"George","Elliot","F"
"Virginia","Woolf","F"
Created with the Personal Edition of HelpNDoc: Full-featured Help generator