Deleting multiple columns inside a datatable


I’m trying to delete some columns inside a data table - which is the output variable from read range activity - before writing the data table into CSV File. I only need some specific columns in the CSV file.
What would be best way to do that? Please suggest.


Download and install below package and then use Select certain Columns activity to read certain Columns. You need to pass DataTable and required Column names in Array of a string format.

Eg. {“Column 1”,“Column 2”,…“Column N”}

1 Like

Hi @ppratz,

you can simply mention columns you require or you want remove in Filter Data Table activity, as shown in below shot,


You can use above highlighted radio buttons to particular apply action.


Hi @samir,

Can we mention all the column names(Column1,Column2,Column3 …etc )under one column value?
If so please tell me how can i do that?

Nope, you have to click on plus (+) to add more column names… as shown in below image.

Instead of adding more no of columns, if you want to remove 1 or 2 columns you can simply select remove radio button and mention columns which you want to remove from datatable.

1 Like

Thanks for the reply

Hello @lakshman , some time ago I saw that you could do something like this using assing and with the following sentence (“[Column1] = ‘value’ AND [Column2] = ‘value’”). CopyToDataTable, could you explain to me what value go in [Column *] and in “Value”


We will use this select query to filter Data based on some columns from DataTable.

For suppose I have input Data with Employee names, Department and Age. And want to filter data whose age is greater than 30 and Department is Finance.

                 dtOutput = dtInput.Select("[Age] > '30' AND [Department] = 'Finance'").CopyToDataTable

Note: If column name is single word then it’s not mandatory to keep Square brackets.


Just make a For Each loop.

Note that each time it loops the column index will reset. So deleting the first three rows would look like {0,0,0}

I needed something similar but my case was simpler, I only needed to keep only the 1st column so I made this little loop to remove the other columns… (see picture)
It removes the 2nd column every time (index =1) and the loop keeps running till we have more than 1 column

But if you wanted to keep specific columns, for example 3 firstname,lastname,salary
you could modify it, do something like this:

First create string array of the columns you need
mycolumns = {“firstname”,“lastname”,“salary”}
Also make an int32 counter like (to remember how many columns you already have):

then change condition so you run it until you have more columns than you wanted

InputDT.Columns.Count > mycolumns.count

and inside you could check if column name is in your list, if yes keep it and increment the index otherwise delete it and keep running the loop

if( mycolumns.Contains( InputDT.Columns(keep).ColumNname )
then assign keep = keep+1
else remove data column with index keep

[EDIT} In case my explanation is hard to understand, I’ve done it for ya:)

Advantage of my solution is you can change the NeededColumns dinamcally (especially if you change it to list instead of string array), that you cannot do in Filter DataTable activity