Baljeet Dhaliwal 2 Posted April 26, 2018 Share Posted April 26, 2018 Hi there Is it possible to fetch a particular cell in a datatable using ironpython without iterating through all the rows. For example: in the table below i want to find sales corresponding to period 2017-2 (i.e. 300) Period Sales 2017-1 400 2017-2 300 2017-3 500 Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted April 27, 2018 Share Posted April 27, 2018 Hello Baljeet, You can use the DataTable.Select() to limit the selection and the retrieve the required value. Can you try the following script from Spotfire.Dxp.Data import * from System.Collections.Generic import List table=Document.ActiveDataTableReference # select an expression to limit the data in a table rowSelection=table.Select('Period = "2017-2"') # Create a cursor to the Column we wish to get the values from cursor = DataValueCursor.CreateFormatted(table.Columns["Sales"]) # Create List object that will hold values listofValues=List[str]() # Loop through all rows, retrieve value for specific column, # and add value into list for row in table.GetRows(rowSelection.AsIndexSet(),cursor): rowIndex = row.Index value1 = cursor.CurrentValue listofValues.Add(value1) for val in listofValues: print val Link to comment Share on other sites More sharing options...
Baljeet Dhaliwal 2 Posted April 27, 2018 Author Share Posted April 27, 2018 Works perfectly. Tried with "and" as well. For example 'Period="2007-1" and Sales>400'. Was wondering if it is possible to get "order by" as well. Could not make that work. Thank you so much. Baljeet Link to comment Share on other sites More sharing options...
Baljeet Dhaliwal 2 Posted April 30, 2018 Author Share Posted April 30, 2018 Is it possible to get "order by" as well. Appreciate any response in advance. B Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted May 1, 2018 Share Posted May 1, 2018 Hello Baljee, The DataTable.Select() takes expression of the Where clause only. So it is not possible to do a OrderBy Link to comment Share on other sites More sharing options...
Rohit Madan 2 Posted November 7, 2019 Share Posted November 7, 2019 Hi Team, I have a similar query. I have a data table. I am taking an input from user from text input field and need to search a column for value to be found or not. if value found, then I want the whole row from the table to be returned. Can you suggest a psudo code for the same. For security reasons, I can't share my progress. But I am new to ironpython and spotfire. I developed the code in regular python (spyder) first and now trying to fit that in ironpython. Please suggest. Thanks in anticipation, Rohit 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