split_fixed

Commands ››
Parent Previous Next

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

Yes

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.

-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: Free HTML Help documentation generator