Rohit Madan 2 Posted November 7, 2019 Posted November 7, 2019 I am trying to take a user input to find a value in a column. If found, I want to return the row (basically something like a iloc/loc function does in pandas package). I need to use a different column value of the row in which the initial different column value is found. I need to put this ironpython script in spotfire. Thanks in Advance, Rohit
Shandilya Peddi Posted November 11, 2019 Posted November 11, 2019 You can use the below sample script to read the user input and then get the column value from that row from Spotfire.Dxp.Data import * from System.Collections.Generic import List table=Document.Data.Tables["SalesAndMarketing"] #get the user Input userInput=Document.Properties["test"] #where clause rowSelection=table.Select("City='"+userInput+"'") # Create a cursor to the Column we wish to get the values from cursor = DataValueCursor.CreateFormatted(table.Columns["Store ID"]) # Create List object that will hold values if there will be multiple values listofValues=List[int]() # 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(int(value1)) print listofValues
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