how to check if a field is in a list of strings

Six Stars

how to check if a field is in a list of strings

there is a flat file with about 100 fields (fixed length)

I would like to filter the records with city in (city1,city2,city3,........city20) and output the file.

Is there any talend function or java function similar sql in () function?

city.equals(city1) || city.equals(city2)||..will work, but it is not convenient 

thank you.


Accepted Solutions
Thirteen Stars

Re: how to check if a field is in a list of strings

StringHandling.INDEX(context.cities,row1.city)!=-1

tMap filter (possible with little modifications for prevent partial matches), also will work

-----------

All Replies
Community Manager

Re: how to check if a field is in a list of strings

Hi JaneYu

No similar function exists yet, however, you can create a routine function and call it in the job whenever you need to call it. Please refer to documentation Creating an user routine and call it in a job

 

Regards

Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business
Thirteen Stars

Re: how to check if a field is in a list of strings

StringHandling.INDEX(context.cities,row1.city)!=-1

tMap filter (possible with little modifications for prevent partial matches), also will work

-----------

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.