split first 3 rocords to one target and last 3 into another

Five Stars

split first 3 rocords to one target and last 3 into another

Hi All , 

I have a Table of 6 records , I need to make 2 targets and first 3 rows will go into target 1 and last 3 rows will move into target 2 . 

I dont want it in even/ odd format with "%2" operation. .

 

Thanks in advance .

 

Regards 

Subhadeep

Forteen Stars TRF
Forteen Stars

Re: split first 3 rocords to one target and last 3 into another

Using a tMap you may have a sequence to count records then, having 2 output flows with the appropriate filters you can separate 3 first records from 3 last.

TRF
Five Stars

Re: split first 3 rocords to one target and last 3 into another

I am not able to find the proper filter condition inside tMap.

Can you please send me the solution for the same ?

Thanks
Subhadeep
Highlighted
Forteen Stars TRF
Forteen Stars

Re: split first 3 rocords to one target and last 3 into another

Define a local variable such as "count" into your tMap. Then on rhe 1rst output flow, define the filter line this: "Var.count <= 3" and for this other one: "Var.count > 3"

TRF
Eight Stars

Re: split first 3 rocords to one target and last 3 into another

Hi @subhadeep,

Greetings of the day,

Well your scenario can be acheived in Tmap by using sequence number function and for this -

i) add a column by name id or something to uniquely define your column and then write a function in the expression builder Numeric.sequence("s1",1,1) and then you can apply filter for spliting the records.

ii)you can try using another component to explore - tsamplerow.

If you are still facing issues,Pls reach out to the Community.

Thanks,

Ankit

Forteen Stars TRF
Forteen Stars

Re: split first 3 rocords to one target and last 3 into another

@subhadeep to complete my first posts, here is what your tMap should look like:

Capture.pngThen if you push these flows to 2 tLogRow components, here is the result:

[statistics] connecting to socket on port 3799
[statistics] connected
.----.
|tLogRow_2|
|=--=|
|Col1|
|=--=|
|1   |
|2   |
|3   |
'----'

.----.
|tLogRow_3|
|=--=|
|Col1|
|=--=|
|4   |
|5   |
|6   |
'----'
[statistics] disconnected

TRF

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.