Five 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.

1 ACCEPTED SOLUTION

Accepted Solutions
Ten 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

-----------
2 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
Ten 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

-----------