Column Assignment based on Content

One Star

Column Assignment based on Content

Hi,
I need to assign a column from an input table to 2 output columns based on the content.
Input Table: (extraction):
1. Salutation
2. Name
Output Table:
1. Salutation
2. Contact
3. Company
The data in the column "Name" (Input) is a mix of company names and private names. If I can find the words "Mr, Mrs, Ms", etc. in salutation I need to assign the content from "Name" (Input) to "Contact" (Output), otherwise it needs to go into "Company".
How can I do this in Talend?
Thank you very much!
Stefan
(Using Talend OS4DI 5.0.2)
One Star

Re: Column Assignment based on Content

Hi Stefan
Welcome to Talend Community!
You might set expression in tMap as seen below.
Contact:
row1.Name.startsWith("Mr")?row1.Name:(row1.Name.startsWith("Mrs")?row1.Name:(row1.Name.startsWith("Ms")?row1.Name:null))

Company:
row1.Name.startsWith("Mr")?null:(row1.Name.startsWith("Mrs")?null:(row1.Name.startsWith("Ms")?null:row1.Name))

Regards,
Pedro
One Star

Re: Column Assignment based on Content

Hi Pedro
Great thanks for your answer!
It is a good and working solution.
Stefan