Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Delete first 10 rows

#dt is a data table script parameter
from Spotfire.Dxp.Data import RowSelection, IndexSet

#select all rows
selection   = IndexSet(dt.RowCount,True)

#mark first 10 rows row as true and the rest false
for r in selection:
   selection[r] = (r<=10)

#delete rows based on selection (rows from indexset marked as true)
dt.RemoveRows(RowSelection(selection))

3 comments:

Unknown said...

Your post has been helpful!
Also, to delete the Last 10 Row from Table using Iron Python Script:


from Spotfire.Dxp.Data import RowSelection, IndexSet
dtTarget=usertable*
selection = IndexSet(dtTarget.RowCount,True)
for r in selection:
selection[r] = (r>=(dtTarget.RowCount-10))
dtTarget.RemoveRows(RowSelection(selection))

VijayTeja said...

Thanks for the post!

It would be great if any one could say how to delete the rows based on a condition in IronPython script.

Like say, there are two columns one with usernames and another with text. As soon as user logins, based on their user name, other rows should get deleted on button click except the rows with the logged in user name. Thanks in Advance!

Jose Leviaguirre said...

Hello Vijay,

It could be possible but I think there are better ways to handle row, column and even schema security levels with TIBCO Data Virtualization (TDV). It should be part of the license in most cases