Keep DataTable Columns Where ColumnName Contains Specific Keyword

@Jugger

Welcome back to our UiPath community.

  1. First find out all the columns whose header contains specific word as below.

arrColNames = (From c in dtInput.Columns.Cast(Of DataColumn) Where c.ColumnName.Contains("specific word") Select c.ColumnName).toArray

Here, arrColNames is of type Array of String

  1. And then try below expression to fetch only required rows with specific header matching columns.

dtOutput = dtInput.DefaultView.ToTable(True,arrColNames)

Note: If you want duplicate records also then write False instead of True.

3 Likes