cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

Deleting columns that are not in a list

Hi Guys,

I have a set of columns that I want to keep and then delete all except this set.

The columns that I want to delete are large in number.

Is there any easy way to do this using a script?

Thanks.
10 REPLIES 10
Von_Andre
Level II

Re: Deleting columns that are not in a list

Hi Dave, Appreciate all the help. Nice blog by the way! I have a very large data set consisting >8000 columns and I have some columns to keep and some don't. I ended up by using subset on the first columns that I want to keep. After which I run a loop on the rest of the table for keeping columns that matches from my keywords like "_M". Then finally join the subset and the table I had kept with column names matching my criteria. It works fine now. However, I then again try to use list on below code but seems not running. Is using of list not allowed on this? dt = Current Data Table(); // select data table dt << Set Name( "Raw_Data" ); dt << Subset( Columns( 1 :: 30 ), Rows( all ), Output Table( "Subset" ) ); // keep main column names dt << Revert(); //Keep vt columns colList = Data Table( "Raw_Data" ) << Get Column Names( String ); For( i = N Cols( dt ), i >= 1, i--, If( !Contains( colList[i], "_M" ), //Keep only columns with "_M"" in the name dt << Delete Column( Column( colList[i] ) ) ) );