Select datatable from one row index to another row index

Hi Team,
I am facing a problem where i need to extract a segment of datatable from a larger datatable, with respect to row indices.
The input is in below format:

The required output will be:


The output will be from 7th row till 13th row.

Hi
To extract a data table segment, use this expression in an assign activity:

DataTableVariable.AsEnumerable.Skip(6).Take(7).CopyToDataTable

Do you also need to dynamically find indexes 7 and 13?

yes…i have found the index as startingindex and ending index

ok, just replace 6 with startingindex and 7 with endingindex-startingindex+1

for the starting index, the bot is taking correct row but for the the 2nd part where you told to use that endrow-startrow+1 for that it is not working, the bot is taking the entire datatable starting from the mentioned starting row.

i gave a fixed number in the take function, like 111 but then also it is taking the entire data starting from the skip part.

Hi, try this:

assign

counter_skip =6 and take = 7

then assign

int_range =Convert.ToInt32(Math.Ceiling(yourdt.Rows.Count / take))

after that use for each with type argument integer
image

Rowset = yourdt.AsEnumerable.Skip(counter_skip).Take(take).ToList
rowset is list of datarow

inside IF activity
image

and dont forget to add counter_skip with 13 because you want to skip 6 and take 7 meaning the last row is 13 then you want to take again start from row 13 and so on

counter_skip = counter_skip+13

Hope this help you,
Cheers

Thanks, it worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.