Skip to main content
Version: Python

How to extract values from tables

Deephaven tables have methods to extract values from tables into the native programming language. Generally, this isn't necessary for Deephaven queries but may be useful for debugging and logging purposes, and other specific use cases such as using listeners.

table.getColumnSource()

The general syntax to extract a specific value from a table is value = table.getColumnSource("column").get(index).

The getColumnSource method allows you to convert a column to a ColumnSource object.

from deephaven import new_table
from deephaven.column import int_col

result = new_table([
int_col("Integers", [1, 2, 3, 4, 5])
])

column_source = result.j_object.getColumnSource("Integers")

print(column_source)

Once you've gotten your column source, you can use its methods. For extracting a table value, you use the get method to retrieve the value of the column at the given index.

print(column_source.get(2))

table.columnIterator()

In cases where you want to loop over all the values in a column, you can use the columnIterator method. This method returns an iterator for all the values in the column.

iterator = result.j_object.columnIterator("Integers")

while iterator.hasNext():
print(iterator.next())