Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi There,
First of all I'm a total newbie to Talend and java so please excuse me if my issue seems very primitive 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
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+"\""
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+"\""
Thank you so much, That just worked like a charm!
Nice thanks but if I compared it to the csv option in the FileOutDelimited component now inside my description text the double quote won't be shown, e.g. you open the csv in excel again.
Inside the string must be wheel size 16"" but if I open the csv in notepad there's only size 16" thats why excel will not recognize the double quote in the description text.