Remove Data Column

Hi friends, I want to remove multiple data columns from a datatable but was stuck doing that. I tried it this way: {“Name”, “affiliation”} but got error 1 dimensional array cannot be converted to string. Please assist


Rather to delete columns from a datatable we can get the number of columns we want using Defaultview method like this
yourdatatablename = yourdatatablename.DefaultView.ToTable(False,”columnname1”,”columnname2”)

So, if I delete the ones I don’t need by using this select method, how do I then get the ones I need

—hope you have that array value ready
—use a for each loop and pass the above array string variable as input
And change the type argument of the for each loop in property panel as string
—then inside the for each loop use a activity called Remove DataColumn activity and mention the datatable name in the datatable property and mention the columnname as item which is the variable from for each loop which has the Columnname…
For more info on this activity

So this would delete column from the datatable we have mentioned in the remove datacolumn activity

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @RPA-botDev


Use Delete Column Activity to delete columns from Excel file.


Hi Lakshman, I have used the delete column activity but I have multiple column names that I want to delete which I used {“lastname”, “firstname”, “subject”} but got the error that one dimensional array cannot be converted to string, please how do I handle that?

Hi @RPA-botDev

Hope this thread could help you on deleting multiple columns


1 Like

So any issues to be discussed
were we able to get this
Cheers @RPA-botDev

Yea @Palaniyappan, thanks, I am working on it now, once I encounter any issue I will let you know

1 Like

Cheers @RPA-botDev

Hi Palaniyappan, I read the dataTable using the read range activityand wants to write a selected column to another datatable. Should I use an assign to filter the selected column. For instance
Datatable Results_of_two_cols = Yourdatatable.Select().CopyToDataTable().DefaultView.ToTable(False, “Date”, “Close”)

1 Like

Yah like this
Results_of_two_cols = Results_of_two_cols.DefaultView.ToTable(False, “Date”, “Close”)
what it means is
we are trying to create a datatable with DefaultView which will give us distinct value when mention as True as first argument or if False as first argument we will be getting all the records, the “Date”,“Close” are the two columns we will be having in the datatable from DefaultView

Cheers @RPA-botDev

Thanks Palaniyappan, the method worked, I’ve extracted the column

1 Like

Cheers @RPA-botDev

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.