Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

treplace, replace null value with "bla", how

Hey, first off thanks for offering such a great forum, from what I have seen it looks like an ideal place for problems to be solved! I've working with Talend for a few weeks now and have run into several operations I'd like to create, but just cannot seem to make work. Currently I'm trying to have talend replace empty rows in a certain column of a csv file.
I simply want rows with blank address fields to be given a default address value of "no address". I've tried tReplace and expressions in tMap but cannot seem to get it going.
in tmap, i tried to put the "replace blank rows with *this*" by putting in:
row3.ADDRESS1.replaceAll("","No Address")
but that just inserts "No Address" after every single character ad nauseam. So i tried:
row3.ADDRESS1.replaceAll('',"No Address")
double single quotes instead of double double quotes... "Invalid Character Constant" error upon run.
Either my syntax is wrong in telling it to "replace empty values in x column with *this*" or im putting it in the wrong place? suggestions?

Labels (3)
11 Replies
_AnonymousUser
Specialist III
Specialist III
Author

forgot to say above, i tried passing the data through a tReplace both before and after the tMap. tried both basic & advanced mode, but again couldn't figure out how to make it look for empty entries.
c0utta
Creator
Creator

Hi Corey,
How about :
row3.ADDRESS1.equals(''") ? "No Address" : row3.ADDRESS1
Cheers,
c0utta
_AnonymousUser
Specialist III
Specialist III
Author

thanks for the speedy reply, i just tried that, it gives me "invalid character constant". (i ran it successfully without, put that in, got the error) that looks like its more along the lines of what is needed though.. got any suggestions for modifying that?
c0utta
Creator
Creator

Hi Corey,
Doh! The first double quote (") was replaced by two single quotes (''). Try this instead:
row3.ADDRESS1.equals("") ? "No Address" : row3.ADDRESS1
Cheers,
c0utta
_AnonymousUser
Specialist III
Specialist III
Author

Brilliant! works perfect, can't thank you enough!
Anonymous
Not applicable

Hi, not sure if this thread is still going, but I get an error when I try to add this:
Exception in component tMap_1
java.lang.NullPointerException
Here is my expression:
(row1.notes.equals("")) ? "No Notes" : row1.notes
Anonymous
Not applicable

Hi ddctf,
This thread is very old. You'd better open a new topic for your issue.
Exception in component tMap_1
java.lang.NullPointerException
Here is my expression:
(row1.notes.equals("")) ? "No Notes" : row1.notes

In addition that, please paste your tMap editor screenshot into the new forum.
Best regards
Sabrina
Anonymous
Not applicable

hi,
the reason it's that you've got some null value for row1.notes ...
use the form
"".equals(row1.notes)

to pass null value or manage them (a better solution)
regards
laurent
Anonymous
Not applicable

"".equals(row1.ID1) ? row2.ID1 : row1.ID1

worked for me, compared to the syntax mentioned before.
Thanks kzone 0683p000009MACn.png