split_char
The split_char command splits a field within a CSV record into a number of sub-fields at boundaries marked by a specific character or sequence of characters. You can also split on transitions between alpha and numeric characters.
See also: split_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. |
-c chars |
No |
Specifies one or more characters which acts as the field separator on which to split the field. By default, this is a single space. Splitting on character is mutually exclusive with the split on transition flags. |
-tan |
No |
Split on first transition from alpha character to numeric character. |
-tna |
No |
Split on first transition from numeric to alpha character. |
-k |
No |
Indicates if the field being split is retained in the output. By default it is removed. |
The following example splits the second field of the emp.cvs file into sub fields delimited by a space :
csvfix split_char -f 2 data/emp.csv
which produces:
"1090M","Jeff","Smith"
"1099F","Annette","King"
"1170M","Bill","Thompson"
"1101M","Jeremy","Fisher"
"1088F","Lynn","Morrice"
This example illustrates splitting on a character type transition. In this case, we split the first field of idname.csv at the transition from number to character:
csvfix split_char -f 1 -tna data/idname.csv
which produces:
"1234","fred","m"
"22","bill","m"
"171171","lynn","f"
Created with the Personal Edition of HelpNDoc: Free Web Help generator