Product: TIBCO Spotfire®
Using an IronPython script to add a data table with a Pivot transformation.
Description: The following example illustrates how to add a data table with a Pivot transformation using an Iron Python script.
Resolution: 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)
Disclaimer:
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment.Make modifications to the script per your implementation specifications that suit best your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
Reference: DataFlowBuilder:
https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/?topic=html/AllMembers_T_Spotfire_Dxp_Data_DataFlowBuilder.htm
Pivot setup:
https://docs.tibco.com/pub/doc_remote/spotfire/6.5.0/api/?topic=html/AllMembers_T_Spotfire_Dxp_Data_Transformations_PivotTransformation.htm
Keywords: IronPython, Script, Pivot transformation, add data table
Comments
0 comments
Article is closed for comments.