我有一个现有的数据表,有两列,一列是ID,另一列是ID列表,用逗号分隔。在
例如
ID | List
---------
1 | 1, 4, 5
3 | 2, 12, 1
我想拆分列列表,这样我就有了这样一个表:
^{pr2}$我现在明白了:
tablename='Querysummary Data'
table=Document.Data.Tables[tablename]
topiccolname='TOPIC_ID'
topiccol=table.Columns[topiccolname]
topiccursor=DataValueCursor.Create[str](topiccol)
docscolname='DOC_IDS'
doccol=table.Columns[docscolname]
doccursor=DataValueCursor.Create[str](doccol)
myPanel = Document.ActivePageReference.FilterPanel
idxSet = myPanel.FilteringSchemeReference.FilteringSelectionReference.GetSelection(table).AsIndexSet()
keys=dict()
topdoc=dict()
for row in table.GetRows(idxSet,topiccursor,doccursor):
keys[topiccursor.CurrentValue]=doccursor.CurrentValue
for key in keys:
str = keys[key].split(",")
for i in str:
topdoc[key]=i
print key + " " +i
现在我可以用相应的id打印主题id。 如何使用dict()在Spotfire中创建新的数据表?在
我终于自己解决了…也许有更好的代码,但它是有效的:
相关问题 更多 >
编程相关推荐