Delete multiple columns from collection
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-04-19 08:46 PM
Folks,
Is there any possible ways we can delete multiple columns at a time from collection?
If yes, Kindly notify please, and if it's possible from code please send code.
Thanks
Salman Ahmed
Salman Ahmed
System Engineer
Asia/Kolkata
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-04-19 12:21 PM
Not enough info. You can just select() columns you need, if you know the field names.
string[] selectedColumns = new[] { ""Column1"",""Column2""};
DataTable outDataTable= new DataView(inDataTable).ToTable(false, selectedColumns);.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-04-19 12:44 PM
Hi Salman,
You can just create collection with these column names in rows and then loop on in with delete action inside.
Best regards
Michal.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-04-19 07:09 PM
Hi Salman,
This is my solution using the code stage( I don't know if there is an action that allow to delete multiple columns ):
The following code deletes all columns from the collection where the column header starts with ""Column"" but you can change the criteria to your needs
BP_Collection_Out = BP_Collection_In
for count as Integer = (BP_Collection_Out.Columns.Count - 1) to 0 Step - 1
if BP_Collection_Out.Columns(count).ColumnName Like Deleting_Pattern then
BP_Collection_Out.Columns.RemoveAt(count)
end if
next
Inputs for code stage:
BP_Collection_In: collection I want to delete the columns
Deleting_Pattern: Your criteria to delete columns
Outputs for code stage:
BP_Collection_Out
Hope this helps.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-04-19 07:03 PM
Thank you all :)
Salman Ahmed
System Engineer
Asia/Kolkata
