Jump to content

Document.Data.Tables.Select... Getting to the data!

Simon Robinson

Recommended Posts



I'm trying to write some python code and need to extract a specific data point from one row in a data table. I'm trying to do it without having to create a cursor to loop through the whole data set (using the Getrows method). The code below appears to isolate the specific row in my table but I can't work out how to reference a specific data point in that row (hence the s!). Can you help My table has3 columns: TableKey, DateKey, Datapoint

myDataPoint= Document.Data.Tables['myTable'].Select("TableKey = 2500").

Something like:

myDataPoint= Document.Data.Tables['myTable'].Select("TableKey = 2500").Columns("Datapoint")

Link to comment
Share on other sites

Hi Simon,

That method returns a RowSelection object, which you can use to get the values from. However, you'll need to "iterate" over the RowSelection as an IndexSet


from Spotfire.Dxp.Data import *


myRowSelection = dt.Select('Promotions = 6')


print myRowSelection


cursor1 = DataValueCursor.CreateFormatted(dt.Columns["Store Name"])


for row in dt.GetRows(myRowSelection.AsIndexSet(), cursor1):

print cursor1.CurrentValuePlease excuse the fact that I have used different variable and column names in my script, but I hope you'll be able to see how to use it.

Andrew (TIBCO Data Science)

Link to comment
Share on other sites

  • 2 years later...



Thanks for the post, this is just what I was looking for. However I am wondering if it is possible to use a value from a document property for the selection criteria.


For example:


myRowSelection = dt.Select('Promotions = Document.Properties["MyDocProperty"]')


I have tried a few different ways of achieving this but haven't had any luck. Any suggestions

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...