Select required columns from datatable

Hi,

Need to select required columns means(if i have 5 columns in a datatable i need to only required columns and need to remove other columns) using linq query

Can’t you use the “Remove Data Column” activity?

thanks for your replay @fmssimoes but if we want filter more columns then we need to write that many of remove data column activities so if it is linq query it may simple to do this

sample ex:

Dim result = dt.AsEnumerable().Where(Function(x) x(“WEATHER”) = “sunny”).[Select](Function(x) New With {Key
.WEATHER = TryCast(x(“WEATHER”), String), Key
.PLAY = TryCast(x(“PLAY”), String)
})

need to implement in uipath , result should be stored again in datatable only…

@kalyanDev Store the columns u want remove in array or list.

Use for each activity with input as that array,
inside loop use for remove “Remove Data Column” activity, in column name property give item variable(item is variable of for each activity)

Thanks for your replay @Manjuts90 i got another way to achieve this with out using for loop and “Remove data column”

1 Like