Simon Robinson Posted September 9, 2016 Share Posted September 9, 2016 Hi, 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 More sharing options...
Andrew Berridge Posted September 12, 2016 Share Posted September 12, 2016 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 More sharing options...
Simon Robinson Posted September 12, 2016 Author Share Posted September 12, 2016 Andrew, that's great thanks very much. I hadn't realised that you could reference the subset within the GetRows method. That's a) worked as I need, and b) made the whole script A LOT faster! Link to comment Share on other sites More sharing options...
Ben Dorrington Posted July 11, 2019 Share Posted July 11, 2019 Hi, 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 More sharing options...
Shandilya Peddi Posted July 11, 2019 Share Posted July 11, 2019 Ben, have you tried something like below value= Document.Properties["MyDocProperty"] myRowSelection = dt.Select('Promotions ='+value) Link to comment Share on other sites More sharing options...
Ben Dorrington Posted July 11, 2019 Share Posted July 11, 2019 Hi Shandilya, I had tried just about everything else :) This works great! Thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now