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

How to give multiple inputs for column selection in jsl

Hi!

 

I'm trying to use the contains function to select multiple columns. After going through the scripting guide, I found an example which gave me a direction, but I don't know how to give multiple inputs. Here's the section of code I'm using:

 

dt = current data table();

colList = dt << Get Column Names(Numeric, "Continuous");

For( i = 1, i <= N Cols( dt ), i++,
	If( Contains( colList[i],"NPT_IRST_"),
		Column( colList[i] ) << Set Selected( 1 )
	)
);

I need to give the following inputs: "NPT_IRST_" , "_NPT" and [ ( open square bracket). How do I give these three inputs?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to give multiple inputs for column selection in jsl

You can expand on the If() condition that you are evaluating, into the 3 comparisons you want.  I believe the below code will get you what you need

Names Default To Here( 1 );
dt = Current Data Table();

colList = dt << Get Column Names( Numeric, "Continuous" );

For( i = 1, i <= N Cols( dt ), i++,
	If( Contains( colList[i], "NPT_IRST_" ) | 
		Contains( colList[i], "_NPT" ) |
		Contains( colList[i], "[" ) 
		,
		Column( colList[i] ) << Set Selected( 1 )
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How to give multiple inputs for column selection in jsl

You can expand on the If() condition that you are evaluating, into the 3 comparisons you want.  I believe the below code will get you what you need

Names Default To Here( 1 );
dt = Current Data Table();

colList = dt << Get Column Names( Numeric, "Continuous" );

For( i = 1, i <= N Cols( dt ), i++,
	If( Contains( colList[i], "NPT_IRST_" ) | 
		Contains( colList[i], "_NPT" ) |
		Contains( colList[i], "[" ) 
		,
		Column( colList[i] ) << Set Selected( 1 )
	)
);
Jim
D_T_M
Level II

Re: How to give multiple inputs for column selection in jsl

Thank you so much for your help!!

As a quick followup, if I try to stack the selected columns in the above case, I'm using the following:

dt << stack(
column(colList),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);

but for some reason, It doesn't stack the selected columns. Any suggestion on how to solve this?