简体   繁体   English

删除spotfire Data Table Iron python上的所有行

[英]Delete all rows on spotfire Data Table Iron python

I was looking for a way to delete rows in my Data table on SPOTFIRE and I didn't find a proper way to do it. 我正在寻找一种方法来删除我在SPOTFIRE上的数据表中的行,我找不到合适的方法来做到这一点。

I tried to code a script to do it, but It's too slow and I have more the 20k rows to be deleted. 我试图编写一个脚本来执行它,但它太慢了,我有更多的20k行要删除。

Does someone have an idea why it's too slow and if there is a another way to do (a faster way) 有人知道为什么它太慢而且还有另一种方法(更快的方式)

from Spotfire.Dxp.Data import RowSelection
table=Document.Data.Tables["my Table name"]
i=0
for row in table.GetRows():
  i+=1
  rowToDelete=Document.Data.Tables["my Table name"].Select("[index]="+`i`).AsIndexSet()
  Document.Data.Tables["my Table name"].RemoveRows(RowSelection(rowToDelete))

I found a way which is more simple to do it. 我发现了一种更简单的方法。

from Spotfire.Dxp.Data import RowSelection, IndexSet
dtTarget = Document.Data.Tables["my Table name"]
dtTarget.RemoveRows(RowSelection(IndexSet(dtTarget.RowCount,True)))

Here is the code which deletes the selected (Marked) rows from the table. 以下是从表中删除所选(标记)行的代码。

from Spotfire.Dxp.Data import RowSelection
DataTable = Document.Data.Tables['NodeCollection']
# selectedNodes - Name of the marking given in spotfire. 
SelectedRows = Document.Data.Markings['selectedNodes'].GetSelection(DataTable)
CollectionTable.RemoveRows(SelectedRows)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM