Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

samplerow how to set the Range

Highlighted
Four Stars

samplerow how to set the Range

Hello,

 

i want to set the Range of the tsamplerow so that every 10th row will be processed

eg. 10,20,30,40,...

in this case i don't now the end of the line or i can set a big end of the range.

such as 10,20,30,40,...,40000 will be possible

how must i set it?

 

Thanks Andreas

Highlighted
Employee

Re: samplerow how to set the Range

Hi,

 

    The most simple way is to add a numeric sequence to your inbound record. Then add an output expression where the reminder of sequence number division by 10 should be zero. In this way, you can pick the records which are 10,20,30, etc.

 

     If you can use a context variable instead of 10, then you can change this from 10 to evry 5 records or every 7 records and so on.

 

    To put an upper cutoff limit, you need to add another output filter condition where the sequence number generated should be less than the upper cutoff number (again a context variable which can be set at beginning of job).

 

    Hope it has helped you Smiley Happy

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Highlighted
Community Manager

Re: samplerow how to set the Range

You might find this easier using a tMap and a modulus operator. For example, look at the tMap I have quickly knocked up below....

Screenshot 2019-03-07 at 14.15.29.png

You will have to excuse the column names. In this example newColumn is your ID column. What I have done is used a filter in the outbound table. What the filter does is only pass the data out for records where the field holding the ID (newColumn) is divisible by 10. The code I have used is below....

row8.newColumn % 10 ==0

This says where the value is divisible by 10 with a remainder equalling 0.

 

Give that a try. You do not need to know the total number of rows for this.

Highlighted
Eleven Stars

Re: samplerow how to set the Range

Or 

 

Use below condition in filterrow ( Use Advance Mode)

 

Mathematical.MOD(Numeric.sequence("s1",1,1),10) == 0.0

 

Do not forget to reset the sequence at the end of subjob.

Regards
Abhishek KUMAR
Highlighted
Four Stars

Re: samplerow how to set the Range

all soulutions work for me.

Thank you very mutch

Highlighted
Employee

Re: samplerow how to set the Range

@af99 

 

Thanks for the confirmation. Could you please close the topic by marking the posts which helped you to get solution?

 

This will help the Talend community when other members are searching for the solutions. Always people will tend to select the topics which are marked as closed with solutions.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog