Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | table | |
Tool | table |
Note that usually such referencing row numbers are 0-based, while the selectrows function expects 1-based row numbers. It means that in such cases 1 should be added (see example).
It is possible to give a name to the resulting table. If given, the resulting table is made persistent with that table name. Otherwise the table is transient and disappears when closed or when Glish exits.
The rownumbers function returns a vector containing the row number in the main table for each row in the selection table. Thus given a row number vector rownrs, the following is always true.
rownrs == maintable.selectrows(rownrs).rownumbers()However, it is not true when selectrows is used on a selection table. because rownumbers does not return the row number in that selection table but in the main table.
rownrs | in | 1-based Row Numbers | |
Allowed: | Vector of Ints | ||
name | in | Name of resulting table | |
Allowed: | Any String | ||
Default: | '' |
# Do the query on the main table. maintable := table('SOMENAME'); scantable := maintable.query(command); # Get the column containing the 0-based row numbers in the BACKEND table. # Make the row numbers unique and make them 1-based. backrows := unique(scantable.getcol('NS_GBT_BACKEND_ID')) + 1; # Form the table subset of the BACKEND table containing those rows. backtable := table('SOMENAME/GBT_BACKEND'); scanback := backtable.selectrows(backrows); # Do something with that table. print scanback.nrows();
The last statement is equivalent to the query command:
scanback := backtable.query("rownumber() in $backrows");However, the query takes much, much, much more time to execute, especially for larger tables and larger row number vectors. Furthermore, the backrows variable need to be global to be able to substitute it in the query command.