Combining and Splitting Data

Combining Data

Sometimes several input columns need to be combined into a single value. For example, if a customer name has two columns in the CSV file:

FIRSTNAME,LASTNAME,...
Bill,Jones,...
Wanda,Wilson,...

Use the combine statement to combine the fields into a single value.

FIRSTNAME -> c.fullName using { combine(value,' ',LASTNAME) }
}

This would produce a value of “Bill Jones” for the first CSV row.

The value keyword means the input value of the current TLANG statement. We could also refer to all the columns by name. The following is equivalent:

FIRSTNAME -> c.fullName using { combine(FIRSTNAME,' ',LASTNAME) }
}

Splitting Data

Sometimes an input column needs to be split into multiple values.

For example, if a customer name has two columns in the CSV file:

FULLNAME,...
Bill Jones,...
Wanda Wilson,...

and our target Delia type has two fields for customer's name:

 firstName string,
 lastName string,
 //...

There are many ways to extract values, such as substring, substringAfter, and substringBefore. The split statement splits a value by the given delimiter

FULLNAME -> c.firstName using { value.split(' ').first() }
FULLNAME -> c.lastName using { value.split(' ').allAfterFirst() }
}

split has a number of sub-functions.

Sub-functionDescriptionExample
first()first split valuesplit(’ ‘).first()
ith(index)get the index-th split valuesplit(’ ‘).ith(2) //get 3rd word
restAfter(index)re-combines all split values after index-th valuesplit(’ ‘).restAfter(0) //get all but first