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

Six 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

Fifteen Stars TRF
Fifteen 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
Six 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
Fifteen Stars TRF
Fifteen 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
Nine 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

Fifteen Stars TRF
Fifteen 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

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch