Search code examples
javaexcelnullpointerexceptiontalendtmap

Special Character filtering with null in talend


I have an excel which has few fields. I want to extract only those fields which has a special character ? in the values. I tried with the contains method in tmap without putting in condition for null but I am getting this NullPointer Exception as the fields also contain blank values in those fields.

Here are the excel file :

enter image description here

Here is the tmap filtering : enter image description here

Here is the error screen :

enter image description here


Solution

  • One or both of the fields in your expression builder has a null in it. You must check for null before performing string contains. Otherwise it will get a null pointer exception

    The below expression will produce a Boolean value of true or false. You can use this expression to filter which rows go onto the output of the tMap

    (row1.Global_Description!=null && row1.Global_Description.contains("?"))|| (row1.Lead_Product_Segment!=null && row1.Lead_Product_Segment.contains("?"))