Remove extra charters from column

Seven Stars

Remove extra charters from column

Hi All,

 

How i can remove the extra string/caracter from column using tmap.

 

Need to remove till 00:00:00  if exist  else ignore.

 

Colum1

28SEP 00:00:00 120

33

20DEC 00:00:00 24

 

Expected output.

colum1

120
33

24

 

Thanks

Shree


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: Remove extra charters from column

Here is a solution:

Capture.PNG

And the result:

Starting job test at 15:33 14/11/2017.

[statistics] connecting to socket on port 4011
[statistics] connected
.-----------+-----+-----+----.
|         tLogRow_13         |
|=----------+-----+-----+---=|
|col1       |col2 |col3 |col4|
|=----------+-----+-----+---=|
|CAID:A70-01|M-001|35/MA|90  |
|CAID:A70-01|M-001|37/MA|51  |
'-----------+-----+-----+----'

[statistics] disconnected
Job test ended at 15:33 14/11/2017. [exit code=0]

TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: Remove extra charters from column

Hi,
You may try this :
row1.column1.replaceAll ("^.*00:00:00 ", "")

TRF
Seven Stars

Re: Remove extra charters from column

Hi @TRF,

 

I am getting java.lang.NullPointerException.

 

Both source and target are string data types.

 

Thanks

Shree

Six Stars PK
Six Stars

Re: Remove extra charters from column

Hi,

 

You have to probably handle null before writing the function.

 

Regards

Prasoon

Forteen Stars TRF
Forteen Stars

Re: Remove extra charters from column

Try using this one:

row1.column1 != null ? row1.column1.replaceAll ("^.*00:00:00 ", "") : null

 


TRF
Seven Stars

Re: Remove extra charters from column

Thanks @TRF,

 

It's working now, there little change in the requirement. I am concatenation some columns then i want split single columns  into mutiple columns. 

 

Source:

Colu1                                                               ,   col2

01SEP00:00:00CAID:A70-01MAM-001,      004935/MA90

CAID:A70-01MAM-001,                               37/MAA/MA51

 

Expected output:

 

      Col1              col2        col3     col4

CAID:A70-01   M-001      35/MA   90

CAID:A70-01   M-001      37/MA   51

 

Rules:

colu1:

1) remove all character before CAID.

2) CAID:A70-01: Lenght of the character is fixed.

3) M-001: Lenght of the character is fixed.

 

Col2:

1) Point posiition "/". Extract before "/" 2 digit i,e  35 and 37.

2) /MA :  is fixed two digit.

3) 90: varience is charcter: curretly consider two digits.

 

Thanks

Shree

Forteen Stars TRF
Forteen Stars

Re: Remove extra charters from column

You should check how regex work with Java with the following link:

http://www.vogella.com/tutorials/JavaRegularExpressions/article.html

Should probably be easier using a tJavaRow than a tMap to solve your case.


TRF
Seven Stars

Re: Remove extra charters from column

Hi @TRF,

 

Sure, Currently i am in middle logic.

 

Would be great if help me using tmap only.

 

Thanks

Shree

Forteen Stars TRF
Forteen Stars

Re: Remove extra charters from column

Here is a solution:

Capture.PNG

And the result:

Starting job test at 15:33 14/11/2017.

[statistics] connecting to socket on port 4011
[statistics] connected
.-----------+-----+-----+----.
|         tLogRow_13         |
|=----------+-----+-----+---=|
|col1       |col2 |col3 |col4|
|=----------+-----+-----+---=|
|CAID:A70-01|M-001|35/MA|90  |
|CAID:A70-01|M-001|37/MA|51  |
'-----------+-----+-----+----'

[statistics] disconnected
Job test ended at 15:33 14/11/2017. [exit code=0]

TRF
Seven Stars

Re: Remove extra charters from column

Thank you so much @TRF,

 

Let me check this code and will update you the same.

 

Thanks

Shree

 

 

Seven Stars

Re: Remove extra charters from column

Hi @TRF,

 

Thanks you so much, its working as expected.

 

Regards

Shree

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.