Two Stars

Tmap insert ' ' to a string

Hi There,

First of all I'm a total newbie to Talend and java so please excuse me if my issue seems very primitive Smiley Happy Anyway my issue is that I'm stuck with figuring out how to insert '' around a string which is red and loaded to tmap from a CSV file. Where it gets complicated is that if the field is null (meaning the column is empty) then the empty column output value should be replaced with null  (as in a string that says null) with out the ' '  around it but if it contains a string, output should be 'string'

 

basically IF column contains a string modify output to 'string'

else modify output to null(string)


so far i have figured out how to check for empty field and insert null by doing

row2.MailingAddressLine1.equals("")?"null":row2.MailingAddressLine1 < this does what i want to do regarding inserting null in to the field

 

And I have tried to do the double quote insertion by doing

StringHandling.TRIM(row2.MailingAddressLine1).length() != 0 ? " 'row2.MailingAddressLine1' ":row2.MailingAddressLine1 < this just replaced 'row2.MailingAddressLine1' for anything that contained a valid string in that column.

 

Have no clue as to how i should combine the two functions in to one maybe and if else statement?

 

Thank you for taking time to read! really appreciate your comments

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: Tmap insert ' ' to a string

Hi,

 

Try this:

row2.MailingAddressLine1.equals("")?"null":"'"+row2.MailingAddressLine1+"'"

or this, if you want double quotes arround the string:

row2.MailingAddressLine1.equals("")?"null":"\""+row2.MailingAddressLine1+"\""

TRF
2 REPLIES
Twelve Stars TRF
Twelve Stars

Re: Tmap insert ' ' to a string

Hi,

 

Try this:

row2.MailingAddressLine1.equals("")?"null":"'"+row2.MailingAddressLine1+"'"

or this, if you want double quotes arround the string:

row2.MailingAddressLine1.equals("")?"null":"\""+row2.MailingAddressLine1+"\""

TRF
Two Stars

Re: Tmap insert ' ' to a string

Thank you so much, That just worked like a charm!