简体   繁体   中英

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.

I tried to code a script to do it, but It's too slow and I have more the 20k rows to be deleted.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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