removing unwanted charcters

Five Stars

removing unwanted charcters

Hello all,

I'm a beginner in talend. I want to pass data by removing unwanted characters present.

I'm having special character coming from source in one of my columns . I want to remove that and process the output. I tried using Treplace component. Tried even Tjavarow.

Can anybody please help me out?Capture.PNG

Thanks in advance. 


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: removing unwanted charcters

You need tu use a regex with String.replaceAll method in a tMap or tJavaRow component like this:

row1.before.replaceAll("[^0-9\\.]", "")

Here is the result:

Démarrage du job test a 10:05 30/05/2018.
[statistics] connecting to socket on port 3820
[statistics] connected
.-------------+-----------.
|       tLogRow_49        |
|=------------+----------=|
|before       |after      |
|=------------+----------=|
|.23          |.23        |
|100          |100        |
|100.         |100.       |
|100.23abc    |100.23     |
|2000.801246…|2000.801246|
'-------------+-----------'

[statistics] disconnected
Job test terminé à 10:05 30/05/2018. [Code sortie=0]

Does this help?


TRF

All Replies
Thirteen Stars

Re: removing unwanted charcters

@snishtala,

 

can you try to replace with in tMap below funtion.

 

row1.column.replaceAll("a","")

or

row1.column.replace("a","")

Manohar B
Fifteen Stars TRF
Fifteen Stars

Re: removing unwanted charcters

You need tu use a regex with String.replaceAll method in a tMap or tJavaRow component like this:

row1.before.replaceAll("[^0-9\\.]", "")

Here is the result:

Démarrage du job test a 10:05 30/05/2018.
[statistics] connecting to socket on port 3820
[statistics] connected
.-------------+-----------.
|       tLogRow_49        |
|=------------+----------=|
|before       |after      |
|=------------+----------=|
|.23          |.23        |
|100          |100        |
|100.         |100.       |
|100.23abc    |100.23     |
|2000.801246…|2000.801246|
'-------------+-----------'

[statistics] disconnected
Job test terminé à 10:05 30/05/2018. [Code sortie=0]

Does this help?


TRF
Five Stars

Re: removing unwanted charcters

@TRF

Thanks a lot mate. It worked with little addition to the expression. I've forgot to mention that i also have some Alphabets coming in that column which i need to pass.

So as an addition to the expression i"ve inserted a-zA-Z in your expression and it worked.

So this is the final expression  

row1.before.replaceAll("[^0-9a-zA-Z\\.]", "")

 Thanks again for taking time and replying to my post.

 

 

Five Stars

Re: removing unwanted charcters

@manodwhb

I've forgot to mention that i also have some alphabets coming in that column which i need to process it to output.Thanks for replying to my post.

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.