Talend-Java string manipulation for Find or Search

One Star

Talend-Java string manipulation for Find or Search

Wondering how i can go about manipulating a text string in tmap. In Microsoft Excel, i was able to do the following functions:
Source: last, first (the goal is to put it in the proper format without the blank spaces.
A B C D
1 Source Data Field length search for "," Correct Format
2 last, first 21 10 first last
=LEN(A2) =SEARCH(",",A2) =TRIM(RIGHT(A2,LEN(A2)-SEARCH(",",A2))&" "&LEFT(A2,C2-1))

Does anybody have any suggestion on how i can write this formula in the Talend tmap expression? What is the Java string expression for (Find or Search)? Thanks! abbig
One Star

Re: Talend-Java string manipulation for Find or Search

What is the real format of the data? Is it a text file with delimited fields?
One Star

Re: Talend-Java string manipulation for Find or Search

The file is in a comma delimited format, but my question is regarding 1 field. The contact names are usually (lastname, firstname), but i want to manipulate the field using tmap properties when i map the fields to the output table in format of (firstname lastname).
One Star

Re: Talend-Java string manipulation for Find or Search

Define the columns in a tFileInputDelimited. Use this for the input to the tMap and in the output field have the rule first + " " + last
One Star

Re: Talend-Java string manipulation for Find or Search

This will not help to solve the problem i am having in switching the names around, because they come in the same field and they space delimited. Do you know if there is an equivalent command in Java/Talend for the "FIND" and "SEARCH" commands in Microsoft Excel?" Thanks!
One Star

Re: Talend-Java string manipulation for Find or Search

Can anyone help me with the expression to parse or split a field(CONTACT) in a table in the tMap environment and to join said field back together in the correct format? (the input file is tab-delimited)
Example: LASTNAME FIRSTNAME (the names have about 4 spaces between them)
Brown John
Smith Mike
Correct Formant: John Brown
Mike Smith

Thanks!
One Star

Re: Talend-Java string manipulation for Find or Search

Look for Java string functions on Google.
or you can use Talend string handling functions such as StringHandling.LEFT(row2.mailbox, row2.mailbox.indexOf("@")) to get the name from an email address. Use LEN and RIGHT to get the part after the "@".
or you could use tExtractDelimitedFields on the field.
One Star

Re: Talend-Java string manipulation for Find or Search

This doesnt work on my project
Win7 64bit
StringHandling.LEFT(row2.mailbox, row2.mailbox.indexOf("@"))
One Star

Re: Talend-Java string manipulation for Find or Search

Why not?
One Star

Re: Talend-Java string manipulation for Find or Search

Look for Java string functions on Google.
or you can use Talend string handling functions such as StringHandling.LEFT(row2.mailbox, row2.mailbox.indexOf("@")) to get the name from an email address. Use LEN and RIGHT to get the part after the "@".
or you could use tExtractDelimitedFields on the field.
One Star

Re: Talend-Java string manipulation for Find or Search

how to achieve string handling for right trim .
example ---> Laks:ram
result ---> ram
I want to fetch characters after ":"
Sixteen Stars

Re: Talend-Java string manipulation for Find or Search

Hi Laks, I am not sure right trim is the best way to describe this. Basically, what you want to use is the code below (assuming the row is "row1" and the column is "myValue"....
row1.myValue.substring(row1.myValue.indexOf(":")+1) 

This uses the Java String "substring" method and "indexOf" method. We find the position in the String of the ":" char with the "indexOf" method, add 1 to it and use that position to start from with the "substring" method.
One Star

Re: Talend-Java string manipulation for Find or Search

Thanks Rhall, It is working perfectly , thanks for the prompt response.