sequence
The sequence command adds sequence numbers to your CSV data. You can specify the starting number, the increment between numbers and whether the number should be padded with leading zeros.
See also: file_info
Flag |
Req'd? |
Description |
-n start |
No |
Specifies the starting value for the sequence - default is 1. |
-i inc |
No |
Specifies the increment between sequence numbers - default is 1. Note that negative increments don't work - use the -d flag instead. |
-d dec |
No |
Specifies decrement between sequence numbers, providing sequences that count down instead of up. Only one of -d and -i can be specified. |
-p pad |
No |
Specifies the width of the field, which will be padded with leading zeros. If not specified, no padding is performed. |
-f pos |
No |
Specifies the field index of the sequence number in the output - default is first field. |
-m mask |
No |
Provides a mask into which the sequence number will be inserted. The insertion point is denoted by the '@' character. So -m 'A@Z' will create sequence numbers like A1Z, A2Z etc. All the other flags are applied to the sequence number before it is inserted into the mask. |
The following example adds sequence numbers beginning at 100 to the names.csv file, padding them to five digits:
csvfix sequence -n 100 -p 5 data/names.csv
which produces:
"00100","Charles","Dickens","M"
"00101","Jane","Austen","F"
"00102","Herman","Melville","M"
"00103","Flann","O'Brien","M"
"00104","George","Elliot","F"
"00105","Virginia","Woolf","F"
"00106","Oscar","Wilde","M"
Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily