在Spotfire中使用脚本创建数据透视表

时间:2017-06-13 19:50:42

标签: ironpython spotfire

我一直在努力让枢轴脚本正常工作。我的问题是准确识别Category,Value和Identity列。

我认为我的标识列很好。我希望Categories(列标题)是SrcTable中“CLASS DESCRIPTION”的唯一值。我希望每个Category列中的值都是Count(CLASS_DESCRIPTION)。因此,如果对于一组标识列,有4个CLASS DESCRIPTION =“403A”实例,我想要一个标题为“403A”且值为4的列。

请参阅下面的我当前的脚本。我评论了我遇到麻烦的部分。

from Spotfire.Dxp.Data import DataFlowBuilder, DataColumnSignature, DataType, DataSourcePromptMode
from Spotfire.Dxp.Data.Transformations import PivotTransformation
from Spotfire.Dxp.Data.Transformations import ColumnAggregation
from System.Collections.Generic import List
from Spotfire.Dxp.Data.Import import DataTableDataSource

SrcTable=Document.Data.Tables["Raw Data"]
ds=DataTableDataSource(SrcTable)
dfb=DataFlowBuilder(ds,Application.ImportContext)
pt=PivotTransformation()
IdentityCols=[]
IdentityCols.append(DataColumnSignature(SrcTable.Columns["LAYER"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["DMS DEVICE"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["SCAN DATE TIME"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["LOT"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["WAFER ID"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["SLOT ID"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["SCAN TOOL"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["TOTAL DEFECTS"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["TOTAL DEFECTS CLASSIFIED"]))
IdentityCols.append(DataColumnSignature(SrcTable.Columns["TOTAL DIE WITH DEFECTS"]))



# HERE'S WHERE MY PROBLEMS ARE STARTING
CategoryCols=[]
CategoryCols.append(DataColumnSignature(SrcTable.Columns["CLASS DESCRIPTION"]))

# IN THIS SECTION, I KEEP GETTING AN ERROR "expected IDataColumn, got ColumnAggregation"
# AT THE LIST2.ADD LINE
list2 = List[ColumnAggregation]()
list2.Clear()
col = SrcTable.Columns['CLASS DESCRIPTION']
colAg = ColumnAggregation(DataColumnSignature(col),'Count')
list2.Add(DataColumnSignature(colAg))
pt.ValueColumns = list2


pt.IdentityColumns=List[DataColumnSignature](IdentityCols)
pt.CategoryColumns=List[DataColumnSignature](CategoryCols)
dfb.AddTransformation(pt)
flow=dfb.Build()
Document.Data.Tables["Wafer Total"].ReplaceData(flow)

感谢您的帮助!

0 个答案:

没有答案