Problem with the StringHandling in a Tmap

Three Stars

Problem with the StringHandling in a Tmap

Hello,

I have a little problem with your component "Tmap", I can not make "StringHandling.SUBSTR ()".

Here is my mistake when I do an execution.
Erreur_StringHandling.PNG

 

Job schema:

Job_StringHandling.PNG

 

The inside of my Tmap:

Tmap_StringHandling.PNG

 

Inside my file (In component: "tFileInputDelimited_1"):

Interieur_fichier_test.PNG

 

My goal at the end of my job is to have on several fields this sentence (that is to say arrived at 52 characters I pass to the next field)
I have for example the line (which I would like to divide into several fields) that is to say:

Example:
"I eat apples."

I would like to have on several fields this sentence (that is to say arrived at 52 characters I pass to the other following field)

Example:

FIELD_1|FIELD_2|FIELD_3
I eat       |apples.  |


I'm a little stuck because I use Talend methods, I can not do it.
Could you help me ?

 

PS: Sorry for my English, I do not have the top level.

Guigui8637

Tags (1)

Accepted Solutions
Seven Stars

Re: Problem with the StringHandling in a Tmap

Si vous voulez diviser la column en taille 52 , 

 

(StringHandling.LEN(row1.command_commantier) > 0  ) ? row1.command_commantier.split("(?<=\\G.{52})")[0]  : null

(StringHandling.LEN(row1.command_commantier) > 52 ) ? row1.command_commantier.split("(?<=\\G.{52})")[1]  : null

(StringHandling.LEN(row1.command_commantier) > 104 ) ? row1.command_commantier.split("(?<=\\G.{52})")[2] : null

 

 

 

 

Regards
Abhishek KUMAR
( Please mark the post as resolved if you found your solution )

All Replies
Seven Stars

Re: Problem with the StringHandling in a Tmap

Bonjour ,

 

il n'y a pas method SUBSTR dans routine StringHandling.

 

Au lieu de , Vous pouvez utilise  row1.command_commantier.SUBSTR( .....)

Regards
Abhishek KUMAR
( Please mark the post as resolved if you found your solution )
Six Stars

Re: Problem with the StringHandling in a Tmap

If you want to get a particular range, you can go with substring. I am not sure in your case you would like to separate each word individually. To do so, split() method would help you

Ex:

 

"I  am a talend developer"

 

Using substring():

row1.substring(8,14) --> O/P - talend

 

using split():

"I am a talend developer"

row1.split(" ")[0]- I

row1.split(" ")[1] -am 

row1.split(" ")[2] - a

 

Three Stars

Re: Problem with the StringHandling in a Tmap

akumar2301,

On the website of Talend help I find this: https://help.talend.com/reader/LyOlwG8xLneDXywyqpc_EA/DhyRyXxfRE5KF4Mw9BmnNQ

And your method does not work.

 

Thank you in advance.

Guigui8637

 

Three Stars

Re: Problem with the StringHandling in a Tmap

Hello avinashbasetty,

 

I used the method: row6.commande_commentaire.substring (53,104)

This is not a long length (This product is not a long length)

 

Here is the error he sends me:

Erreur_substring.PNG


Thank you in advance for your answers and help.
Regards,

 

Guigui8637

Highlighted
Seven Stars

Re: Problem with the StringHandling in a Tmap

Hello,

 

   Could you please try the attached details?

 

Capture1.JPG
Capture2.JPG

 

 

 

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


Warm Regards,
Manish
Seven Stars

Re: Problem with the StringHandling in a Tmap

Si vous voulez diviser la column en taille 52 , 

 

(StringHandling.LEN(row1.command_commantier) > 0  ) ? row1.command_commantier.split("(?<=\\G.{52})")[0]  : null

(StringHandling.LEN(row1.command_commantier) > 52 ) ? row1.command_commantier.split("(?<=\\G.{52})")[1]  : null

(StringHandling.LEN(row1.command_commantier) > 104 ) ? row1.command_commantier.split("(?<=\\G.{52})")[2] : null

 

 

 

 

Regards
Abhishek KUMAR
( Please mark the post as resolved if you found your solution )

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.