One Star

split column fields into two column using tmap

Hi
I have two types of file names in column "File" with datatype String
First : A.csv.bad.currentdate
Second: A.csv.good.currentdate
I want to split these filenames into two column, Good and Bad
So from tmap output, would be like this
Good                                          Bad
A.csv.good.currentdate               A.csv.bad.currentdate
may I know how I can I set up this config in tmap ?
6 REPLIES
One Star

Re: split column fields into two column using tmap

Can anyone Help ?
Community Manager

Re: split column fields into two column using tmap

Write a small piece of Java code to cut the string, for example, 
the expression for the good string:
row1.data.substring(row1.data.lastIndexOf(":")+1)
the expression for the bad string:
row1.data.substring(row1.data.IndexOf(":")+1,row1.data.indexOf("\r\n"))
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: split column fields into two column using tmap

Hey Shong
Here is my output....Please check
http://prntscr.com/9px09l

I want to split "File" Column into two columns, "Bad" and "Read".
So output would be like this
http://prntscr.com/9px2hy

May I know how can I do this in Tmap ?
One Star

Re: split column fields into two column using tmap

Hey Shong, Can you suggest me for the same ?
One Star

Re: split column fields into two column using tmap

Anyone ?
Community Manager

Re: split column fields into two column using tmap

Hi 
Use a tMap to generate two output tables, add a filter condition to filter the reject rows for reject table or bad rows for bad table, for example:
row1.file.contains("bad")
Add a sequence id for each table for doing join in the next subjob to merge the bad and reject columns, see

Hope it helps.
----------------------------------------------------------
Talend | Data Agility for Modern Business