Skip to main content

## 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: -p 1:10,14:2 says that the field should be split into two sub fields, the first starting at position 1 (the beginning of the field) and having length 10, and the second starting at position 14 and having length 2. Fields positions may overlap. A field position may specify a length which extends beyond the bounds of an actual input field, in which case the non-existent characters are ignored. 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

####