Dynamic datatable handling - getting all rows from one dt to another but picking only certain columns specified by condition

filter-datatable
#1

Hey everyone,

I am trying to use VB .net methods to filter a datatable instead of using filter datatable or other available finished activities (supposed to be awarding negative points). In this I am using values stored in the config file to control which columns I need to extract. It works fine with remove data column (could also use add datacolumn when assinging to another table, but I figure that I can just use the table that the scraper provides me with).

So my problem is that when I try to just use eg. datatable.select method I can’t make it work. I have tried other approaches such as iterating through rows and table.columns, but I cant make it work.

In detail - I try to assign three columns out of five extracted columns, and for each row in that table to the other table. I have managed to do it dynamically using available activities and using a config file but I want to use VB .net code instead.

Appreciate any help provided.

Regards
Johan

#2

@johan.standeus

What error are you getting here ?

could you please paste your expression here and will check it once.

#3

@johan.standeus

Hi,

You can take use of linq here.

(from dr as datrow in dt where dr.item(“ColumnName/IndexNumber”=“SomeString” select {dr.item(0),dr.item(1)}).CopyToDataTable

#4

Well, several to be honest and I do not have the will or the energy to recreate the scenarios for now (I am finished with the certification) and I used another solution to my dynamic problem. Often it would not return any errors until I tried to run the process, but it would also return strict on errors.

The dt.select method seems to work when I want to get a specific set of values from a certain column, eg. dt.select(“Type = ‘WI5’”). But it did not work when I wanted to get an entire column (get the entire Type column, not just where Type = WI5.