How to open all the tables within a namespace in your console
When examining new data or monitoring a set of tables, you may want to show all of the tables in a namespace in your console. The following Groovy snippet shows all of the tables for the DbInternal namespace, using variable names equal to the table name.
ns="DbInternal"
db.getTableNames(ns).sort().each{
publishVariable(it, db.i(ns, it).where("Date=currentDateNy()"))
}
We will unpack the syntax below and explain how you can modify this script to work with your data.
Syntax |
Explanation |
---|---|
|
Sets the variable named " |
|
Gets the list of table names in that namespace |
|
Sorts the String names, using the default order (ascending) so that the variables are defined in a predictable order. New tabs in the console are created in that order. |
|
For each of the string names, this executes the following Groovy closure, which we define inline. The closure is executed once for each name in our list. |
|
Creates a variable with the string contained in " |
|
The second argument to |
|
This filters your data to the current day. This |
|
Close the |
|
The end of the closure each began |
The entire command can be written in one line by adding a semi-colon and removing line breaks:
ns="DbInternal";db.getTableNames(ns).sort().each{publishVariable(it, db.i(ns, it).where("Date=currentDateNy()"))}
The following example shows the script as written using Python:
ns="DbInternal"
for tn in db.getTableNames(ns).toArray():
globals()[tn] = db.i(ns, tn).where("Date=currentDateNy()")
Last Updated: 16 February 2021 18:06 -04:00 UTC Deephaven v.1.20200928 (See other versions)
Deephaven Documentation Copyright 2016-2020 Deephaven Data Labs, LLC All Rights Reserved