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

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch