Jump to content
  • Using Data Table Hierarchy to Iterate over Values in Column in Spotfire® Using IronPython Scripting


    ```The sample code below shows how to access the leafs for a column in the hierarchy of a table. This example iterates over all the values in a column. If you have millions of rows in a table but only a handful of different values in a column, this will only iterate once for each distinct value.

    Introduction

    The sample code below shows how to access the leafs for a column in the hierarchy of a table. This example iterates over all the values in a column. If you have millions of rows in a table but only a handful of different values in a column, this will only iterate once for each distinct value.

    There is also an attached file containing this example iterating over the values instead of all rows to make a list of all values.

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    from System import Array
    
    allDistinctValues = []
    
    nodes=Document.Data.Tables['myLargeTable'].Columns['myColumn'].Hierarchy.Levels.LeafLevel.TryGetNodes(int.MaxValue)
    for nval in nodes[1]:
    	allDistinctValues.Add(nval.FormattedValue)
    
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...