Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Sil_B
Contributor
Contributor

TALEND - Keyword in a file

Hello,

My problem seems very simple, but I've been stuck for a long time.

I need to read a file and check if it contains a keyword.

Example

if in bob.txt there is the word "boby" -> action 1 otherwise action 2

It looks so simple.... 😞

Thanks in advance

Labels (2)
1 Reply
Anonymous
Not applicable

Hi

You can read the file content as a string using tFileInputRaw component, then check the string if it contains a keyword "body",

tFileInputRaw--tJavaRow--runIf1--action1

*******************************--runIf2​--action2

 

on tJavaRow:

if(input_row.content.toString().contains("body")){

globalMap.put("key",true);

}else{

globalMap.put("key",false);

}

 

set the condition of runIf1 as:

(boolean)globalMap.get("key")

 

set the condition of runIf2 as:

!(boolean)globalMap.get("key")

 

when the key is true, action1 will be triggered, otherwise, action2 will be triggered.

 

Hope it helps!

 

Regards

Shong