Priyank Dwivedi Posted July 5, 2023 Share Posted July 5, 2023 I would like to get filtered values from a column in IronPythonThe below code somehow gives me 'ALL' values from a column instead of filtered values.Can someone suggest what am I doing wrong?import clrclr.AddReference('System.Data')from System.Data import SqlClientfrom Spotfire.Dxp.Framework.ApplicationModel import NotificationServicefrom Spotfire.Dxp.Data import DataColumn, DataType, DataTablefrom Spotfire.Dxp.Application.Filters import FilteringSchemefrom Spotfire.Dxp.Data import DataSelectionfrom Spotfire.Dxp.Data import *from System.Collections.Generic import Listfrom Spotfire.Dxp.Data import DataValueCursorfrom Spotfire.Dxp.Data import RowSelectionfrom datetime import datetimefrom System.Collections import ArrayListfrom System.Threading import Threadfrom Spotfire.Dxp.Application.Filters import ListBoxFilter def getFilteredItemValues(dataTable, filterObject, columnName): itemList = [] filteredRows = filterObject.FilteredRows myColCursor = DataValueCursor.CreateFormatted(dataTable.Columns[columnName]) for row in dataTable.GetRows(filteredRows,myColCursor): # cursorValue will now contain the value for the column at the current row position cursorValue = myColCursor.CurrentValue itemList.append(cursorValue) return itemList # define Column...colName = "Api_No14" #get a reference to the listbox columnfilt=Document.FilteringSchemes[0][myDataTable][myDataTable.Columns[colName]].As[ListBoxFilter]() # Get ValueswellList2 = getFilteredItemValues(myDataTable, filt, colName)print(wellList) Link to comment Share on other sites More sharing options...
Gaia Paolini Posted July 7, 2023 Share Posted July 7, 2023 You refer to dataTable and to myDataTable in the script. If I substitute every "dataTable" with "myDataTable" (input parameter for my chosen data table) if works for me. Did you mean to have two separate data tables?Also minor problem, change the last line to print(wellList2) to avoid error.If you want to print only the unique values, it is more convenient to use print(set(wellList2)) 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