I'm trying to select all columns which have the attribute "Units", and where the "Units" attribute has a value of "kg/hr". Is there some way to do a clean selectWhere, or do I need to iterate through each column to collect them?
Selecting columns with specific properties, such as "Units", can be done without JSL from the Cols->Columns Viewer menu by clicking on the "Find Columns with Properties" button and then selecting the "Units" check box. This will return a table with a 'Yes' or 'No' for the "Units" property. Sorting this table by right-clicking and selecting "Sort by column..." and then selecting "Units" will make it easy to select all columns with a "units" property.
However, to select a specific unit, such as "kg/hr", would require iterating through your columns as you guessed. This would only take a few lines of JSL, something like:
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
If( Column( i ) << Get Property( "Units" ) == "kg/hr",
Column( i ) << set selected
)
);
Hope this helps.
As far as I know, there is no existing function that would spare you from iterating through your columns and checking them individually. You could subset the columns you need to look at by getting a list of all numeric columns (e.g. numeric_cols = dt << Get Column Names(Numeric, Continuous)). Unless you have a ridiculous number of columns, that probably won't make a noticeable difference in reducing compute time to execute that task. Luckily, it's not very hard to do.
Selecting columns with specific properties, such as "Units", can be done without JSL from the Cols->Columns Viewer menu by clicking on the "Find Columns with Properties" button and then selecting the "Units" check box. This will return a table with a 'Yes' or 'No' for the "Units" property. Sorting this table by right-clicking and selecting "Sort by column..." and then selecting "Units" will make it easy to select all columns with a "units" property.
However, to select a specific unit, such as "kg/hr", would require iterating through your columns as you guessed. This would only take a few lines of JSL, something like:
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
If( Column( i ) << Get Property( "Units" ) == "kg/hr",
Column( i ) << set selected
)
);
Hope this helps.
Hi,
i create for my columns a property called METADATA with info TEST
when i tried to select this columns the script doesn't show error, but the columns are not selected
can you help me?