Delete top two rows in DT .. not working

Hi

I’m working with an excel which has 35+ columns and I need only some of the columns and not all. The data table starts from A3 cell i.e. the column header is from 3rd row. Top two rows have some information that can be deleted.

I used below expression to delete top two rows

DT_Var.AsEnumerable.Skip(DT_Var.Rows.IndexOf(DT_Var.AsEnumerable.Where(Function(r)r(0).ToString.Trim.Equals(Header) ).ToArray(0) ) ).CopyToDataTable

Header is one of the columns name in the header. So this will give the index of the header

but when I tried using Filter Data Table to keep only the required columns I 'm getting column name not present error.

Debugging - I used write range activity to check if datatable is as per expectation with header and it turned out to be as per expectation. But when I tried using write CSV activity to check if this comes as the excel output from write range, the out put of csv was different. The top two rows which are supposed to be skipped/deleted in DT are present and in the 2 nd row there are column names as Colum0, Column1 i.e. on top of the actual header

So the DT is still having two 2 row but when writing to excel with write range they are skipped. This is kind of strange and I’m wondering if i missed anything here

any help will be helpful

Hi @AdityaVN ,

Maybe some parts are not very clear as we do not have a visual representation of the Input and the Output that you are receiving, but if you do already know that the Header starts from A3, then specifying the Range in Read Range activity as A3 should help you get the datatable with the headers as required.

Let us know if the above method does not work and let us know some more details as to why.

@AdityaVN

Use “Remove Data Column” activity.
Under ColumnIndex, enter the index or indices of the column(s) you want to remove, separated by commas. For example, if you want to remove columns 2 and 4, enter “2,4” (without the quotes).