V S Posted November 1, 2018 Share Posted November 1, 2018 Hi, I am trying to write a script to iterate over all the columns in a data table. from Spotfire.Dxp.Data import * dataTable = Document.Data.Tables["Test"] print dataTable.Name cursor = DataValueCursor.CreateFormatted(dataTable.Columns["ColumnA"]) valList = List [str](); #iterate through table column rows to retrieve the values for row in dataTable.GetRows(cursor): value = cursor.CurrentValue if value str.Empty: valList.Add(value) Using above code, it means I have to create a cursor object for each column and create for loop for each cursor object Is there a better way to loop through all columns and do necessary operations Thanks for help. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted November 7, 2018 Share Posted November 7, 2018 To read row values of a column, you will have to create the respective cursor. In this case you will have to create a cursor for each column to read the values of that column. Also you don't have to create a separate loop for each column, you can just specify all the cursors in the dataTable.GetRows(cursor,cursor1) , something asbelow cursor = DataValueCursor.CreateFormatted(dataTable.Columns["ColumnA"]) cursor1 = DataValueCursor.CreateFormatted(dataTable.Columns["ColumnB"]) valList = List [str](); #iterate through table column rows to retrieve the values for row in dataTable.GetRows(cursor,cursor1): value = cursor.CurrentValue if value str.Empty: valList.Add(value) Link to comment Share on other sites More sharing options...
Tom Tang 2 Posted October 10, 2019 Share Posted October 10, 2019 hi I think below code is not correct if value <> str.Empty: it should be if value <> "(Empty)": since the empty cursor value is not same as an emtpy string "" 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