4
votes

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))
2
what's your use case? why are you trying to delete from the data table? - niko
I have multiple dataTable embeded in Spotfire, and a Global DataTable that is based on the Embeded DataTable. I need to delete Data from One Data Table, so i can do just a refresh to on the Global DataTable without re-creating the global DataTable and insert all the rows from the temps tables. - Ayyoub

2 Answers

9
votes

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)))
1
votes

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)