split_fixed
The split_fixed command splits a field into sub fields based on fixed positions.
See also: split_char, read_fixed
Flag |
Req'd? |
Description |
-f field |
Yes |
Index of the field that you want to split. The first field in a row has index 1. |
-p poslist |
No |
Specifies a list of positions at which the field should be split. Each position consists of a start and a length separated by a colon. For example: This option is mutually exclusive with the -l option. |
-l lengths |
No |
Specifies a list of sub-field lengths that will be used to split the field. The lengths are applied starting at the left-hand side of the input field. A single * character may be used to indicate that a field has variable length. For example: -l 2,*,3 says split into the first 2 characters, the last 3, and any number of characters between these. |
-k |
No |
Indicates if the field being split is retained in the output. By default it is removed. |
The following example splits the first field of the emp.csv file into numeric employee number and sex indicator:
csvfix split_fixed -f 1 -p 1:4,5:1 data/emp.csv
producing:
"1090","M","Jeff Smith"
"1099","F","Annette King"
"1170","M","Bill Thompson"
"1101","M","Jeremy Fisher"
"1088","F","Lynn Morrice"
Created with the Personal Edition of HelpNDoc: Full-featured Help generator