4.56 left - Extract String from Left

Format 1: left($str$, length)

Format 2: leftw($str$, length)

Extract specified number of characters from the left as defined in the length parameter from the character string $str$. Use leftw if the string contains multibyte characters.

Examples

Example 1: Basic Example

Extract the first 3 characters in the str column.

$ more dat1.csv
id,str
1,abcdefg
2,12345678
3,
4,12
$ mcal c='left($s{str},3)' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=left($s{str},3) i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,str,rsl
1,abcdefg,abc
2,12345678,123
3,,
4,12,12