Jump to content
  • How to add a data table with a Pivot transformation using IronPython in Spotfire®


    This example illustrates how to add a data table with a Pivot transformation using an Iron Python script.

    Introduction

    This example illustrates how to add a data table with a Pivot transformation using an Iron Python script.

    Code sample

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Data import DataFlowBuilder, DataColumnSignature, DataType, DataSourcePromptMode
    from Spotfire.Dxp.Data.Transformations import PivotTransformation
    from System.Collections.Generic import List
    from Spotfire.Dxp.Data.Import import DataTableDataSource
    table = Document.Data.Tables['TestData']
    
    ds = DataTableDataSource(table)
    ds.IsPromptingAllowed = False
    ds.ReuseSettingsWithoutPrompting = True
    dfb = DataFlowBuilder(ds, Application.ImportContext)
    pivot = PivotTransformation()
    list = List[DataColumnSignature]()
    list.Clear()
    col = table.Columns['Random']
    list.Add(DataColumnSignature(col))
    pivot.IdentityColumns = list
    
    # Category columns.
    #col = table.Columns['Active']
    #list.Add(DataColumnSignature(col))
    #col = table.Columns['County']
    #list.Add(DataColumnSignature(col))
    #pivot.CategoryColumns = list
    
    dfb.AddTransformation(pivot)
    flow = dfb.Build()
    Document.Data.Tables.Add("nip",flow)
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...