Aleem_Khan
(Aleem Anwer)
October 31, 2022, 1:41pm
1
Hi Guys
I need you help to understand in which scenario we can use skip() and Take() method togather
like below query use to split excel into chunks
ExampleExcel.zip (235.0 KB)
Split_Excel_Files.xaml (18.1 KB)
dt_Input.AsEnumerable.Skip(int_Boundry_Start_Row-1).Take(int_Split_Row_Count).CopyToDataTable
ppr
(Peter Preuss)
October 31, 2022, 1:46pm
2
Have a look here:
This HowTo gives an introductory overview of the partition Operators: Skip, Take, SkipWhile, TakeWhile
Introduction
The partition operators are used to fetch a particular subset from a set of items. The returned subset is formed by the contiguous items that are matching the provided condition.
Skip / Take Operator
The Skip Operator will omit the subsequent items from the given start for a given length and will return the remaining items
The Take Operator will return the subsequent items fr…
And have some practicals here:
@christine.tzenghy
let me introduce a general approach that can be also adopted to more case specific details.
Assumptons:
DataTable with 8 Rows
Segmentsize: 3
Following Building Blocks are used
Calculation of the numbers of segments:
[grafik]
with the Ceiling method the fractions are uprounded to the next Integer
with the Skip() and Take() Method the Rows for a segment can be retrieved.
the different segments are bult by following
[grafik]
and do fetch the different segment rows by: …
Aleem_Khan
(Aleem Anwer)
November 7, 2022, 4:09pm
3
Can anyone help me on this topic
Yoichi
(Yoichi)
November 8, 2022, 2:14am
4
HI,
How about the following?
Enumerable.Range(0,(dt.Rows.Count \ chunkSize)+1).Select(Function(i) dt.AsEnumerable.Skip(i*chunkSize).Take(ChunkSize).CopyToDataTable).ToArray
Sample20221108-4.zip (132.8 KB)
Regards,
2 Likes
Hi @Yoichi , Thank you for above solution.
I have a similar requirement where a large data table has 3000 records which would be spilt in 3 files with 900 records/file and remaining 300 would go in a separate file.
3000 is just a number, it can be 5000 but records per file is fixed; 900 so remaining will go in a new file.
Any suggestions.
ppr
(Peter Preuss)
August 29, 2024, 8:30am
6
we suggest to open a new topic on your case and get individually help
Preview:
Assign Activity:
TableList | DataType: List(of DataTable) =
dtDataVar.AsEnumerable.Chunk(SegmentSizeAsIntVar).Select(Function (x) x.CopyToDataTable).ToList
UPD1 - added preview on calculation of Fixed, Remaining rest Skip Take calculations:
1 Like
Thank you @ppr , this should work
Hey @ppr , chunk function is showing up. As you suggested, I created a variable of type list of datatable (List).
@Yoichi any idea?
Yoichi
(Yoichi)
August 30, 2024, 2:57am
9
Do you have any problem? We can iterate the list using ForEach, then Save each item into xlsx file using WriteRange activity etc.
Regards,
The problem is chunk function in below query in not showing in my studio.
dtDataVar.AsEnumerable.Chunk (SegmentSizeAsIntVar).Select(Function (x) x.CopyToDataTable).ToList
can we have a query something using range function?
Yoichi
(Yoichi)
August 30, 2024, 3:51am
11
Hi,
Is your project Windows-Legacy? If so, Chunk cannot be used.
Regards,
Yes, it is window-legacy.
Is there any alternate function of chunk in legacy projects ?
Yoichi
(Yoichi)
August 30, 2024, 3:59am
13
Hi,
Doesn’t this post work for you?
HI,
How about the following?
[image]
Enumerable.Range(0,(dt.Rows.Count \ chunkSize)+1).Select(Function(i) dt.AsEnumerable.Skip(i*chunkSize).Take(ChunkSize).CopyToDataTable).ToArray
Sample20221108-4.zip (132.8 KB)
Regards,
Regards,
It does, thank you for the quick response
ppr
(Peter Preuss)
August 30, 2024, 7:53am
15
ramvashista85:
chunk in legacy projects
yes, that is
why we have shared with you the approach of calculating Skip, Take Blocks
However, for any further question just open a new topic and get individually help on your case as already mentioned