How to delete some above rows in a datatable

Hii Please help,

Explaining scenario:
I have a datatable, from 9th row i have my desired data, so i wanted to delete the above rows and make my 9th row as 1st row.

Please help

Hi,

Can you try the following expression?

dt = dt.AsEnumerable.Skip(8).CopyToDataTable

Regards,

2 Likes

sorry, Just for the example i said 9th rows, Please provide some universal answer

Hi,

If you need to delete rows above the n-th row, the following will work

dt = dt.AsEnumerable.Skip(n-1).CopyToDataTable

Note : n is Int32 variable.

Regards,

Hello if, you want to go in simple way you can use

For each data table row and pass your data table variable.

and also create output variable of for each
image

and use if condition check output variable <=8
image
in true conditon use remove data table activity and paas row index variable and data table variable.
and Else condition use add data row activity and create another new data table that use starting index with 9

Hi @Dummy

How about this expression

(From d In Dt.AsEnumerable let ra = d.ItemArray.Skip(9).toArray Select DtOutput.Rows.Add(ra)).CopyToDataTable

Regards
Gokul

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