Search one column and replace another column with value if matched

Six Stars

Search one column and replace another column with value if matched

I'm trying to do a search on one column, and if the field matches a pattern or value, then a different column in the row gets a value. 

What is the proper way to do this?

 

Forteen Stars

Re: Search one column and replace another column with value if matched

check tReplaceList make 2 inputs from the same file 

-----------
Six Stars

Re: Search one column and replace another column with value if matched

This seems like a brutal workaround, why doesn't replace offer separate lookup/replace columns?

I'm also completely unsure how you propose I use treplacelist, what do you mean two inputs?   

Forteen Stars

Re: Search one column and replace another column with value if matched

there are many ways could help to achieve the same result, you task - check and choose the best for you (especially when you did not share all information ;-) )

 

but all of them as described require self-join - multiple use the same table as different source and join them

it could be tMap with main flow and 1-* lookup inputs, it could be tReplaceList, in all cases - as you describe you want to search not in the same row, but in all rows from a different column, so you will need for each row from main flow make a lookup for all rows from lookup columns

-----------
Six Stars

Re: Search one column and replace another column with value if matched

Woah,  not all rows, the other column is known beforehand and will be in the same row.

Six Stars

Re: Search one column and replace another column with value if matched

Don't need to search all rows, the other column is known beforehand and will be checking a field in the same row.

 

 

Six Stars

Re: Search one column and replace another column with value if matched

Given example:

column_1, column_2, column_3
AAA, BBB, CCC
AAA. BBB, CCC
AAB, BBB, CCC

So for each row, if column_1 = "AAA", then column_3 = "DDD", The expected output would be:

column_1, column_2, column_3
AAA, BBB, DDD
AAA. BBB, DDD
AAB, BBB, CCC
Highlighted
Forteen Stars

Re: Search one column and replace another column with value if matched

Hi,

 

if all in same row, it is simple:

in tMap in col3 put

col1.equals("AAA")?"DDD":col3
-----------
Six Stars

Re: Search one column and replace another column with value if matched

Not a bad option, I've used one just like that prior, but is there any way to handle a large amount of them?

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

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch