How to split datatable for each iteration

Hi ,

I have excel data of 100 records, each time bot needs to run and generate output report only with 10 items ,once first 10 records are processed it needs to pick from 11 th to 20,21 to 30 and so on

Thanks in advance

Hi @Kishore_Raj

Check out this thread

In Additional to above find a compacted variation:

Assign Activity:
SegmentSize | Int32 = 50

Assign Activity:
NoOfSegments | Int32 = Convert.ToInt32(Math.Ceiling(dtData.Rows.Count / SegmentSize))

Assign Activity:
TableList | List(Of DataTable) =

Enumerable.Range(0,NoOfSegments).Select(Function (x) dtData.AsEnumerable.Skip(x*SegmentSize).Take(SegmentSize).CopyToDataTable).ToList()
For each Activity: item in TableList | TypeArgument: DataTable

Log Message: item.Rows.Count.ToString()

Hope it helps!!

Hi,

If you use Windows project, Chunk method will help you, as the following.

Regards,

This should not happen in one go

in the input excel i have 100 records from this i need to run and generate output report with 10 records each time
in the first run it should complete 10 records out of 100 records and generate output file and stop and
in the second run it should complete 10 records from 11 to 20 and generate file and stop and so on it should run in schedules

Hi,

If you can write information for status to the xlsx, the following may help you.
(When process some row, write status Done in the row. In next run, if status is “Done”, it will be skipped.)

Regards,

Hi @Kishore_Raj

startIndex = 0
batchSize = 10
While startIndex < inputDataTable.Rows.Count
  outputDataTable=inputDataTable.AsEnumerable().Skip(startIndex).Take(batchSize).CopyToDataTable()
  Writerange
  startIndex = startIndex + batchSize
End While

Hope it helps!!

Hi @Kishore_Raj ,

Solution from Techystack youtube channel.

Video Link:- https://youtu.be/UqOqwyuQVjk (If you are not able to see this video it may in private mode this will be public by next week of wednesday)

Mean while you can check the code which i have attached.

Filter with Linq And Filter Data Table Solution-N0-4.xaml (17.8 KB)

Regards,
Pavan Kumar

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