Pei Hsuan Shen Posted March 21, 2020 Posted March 21, 2020 When I type the program below. It shows that "TypeError: expected DataTableDataSourceUpdateBehavior, got RowSelection".But I refer to the API documentation. The version of the DataTableDataSourceUpdateBehavior and RowSelection is too old to use. (I am using version 10.0.) What can I do to write the code to get the filtered rows to form a tableCan someone tell me how to rewrite the code between ### and ### Thanks. from Spotfire.Dxp.Data import DataFlowBuilder, DataColumnSignature, DataType, DataSourcePromptMode, IndexSet, DataValueCursor from Spotfire.Dxp.Data.Import import DataTableDataSource #Define table name table = Document.Data.Tables['cloth'] priority = ['XXL', ' XL', ' L', ' S', ' M'] RowCount=table.RowCount rowsToInclude=IndexSet(RowCount,True) size = DataValueCursor.CreateFormatted(table.Columns["size"]) for item in priority: count = 0 for row in table.GetRows(rowsToInclude,size): rowIndex = row.Index if size.CurrentValue ==item: count += 1 if count == 1: ######### cursor = table.Select(" = " + item) table=DataTableDataSource(table,cursor) break ######### else: if item == 'Z' and count > 1: ######### cursor = table.Select(" = ' '") table=DataTableDataSource(table,cursor) ######### else: pass
Pei Hsuan Shen Posted March 23, 2020 Author Posted March 23, 2020 Can someone help me It's really important to me. I have referred to the document below. But it doesn't work at all. (https://docs.tibco.com/pub/doc_remote/sfire-analyst/10.0.0/doc/api/html/M_Spotfire_Dxp_Data_Import_DataTableDataSource__ctor_1.htm)
Khushboo Rabadia Posted March 23, 2020 Posted March 23, 2020 You can use below iron python scripts to create another data table using filtered rows: https://community.spotfire.com/wiki/how-add-new-data-table-based-existing-data-table-analysis-tibco-spotfirer-using-ironpython https://community.spotfire.com/wiki/how-create-data-table-based-filtered-rows-another-data-table-tibco-spotfirer-using-ironpython Your script would not work as you are passing Rowselection object instead of DataSelection
Pei Hsuan Shen Posted March 24, 2020 Author Posted March 24, 2020 from Spotfire.Dxp.Data import DataFlowBuilder, DataColumnSignature, DataType, DataSourcePromptMode, IndexSet, DataValueCursor from Spotfire.Dxp.Data.Import import DataTableDataSource #Define table name table = Document.Data.Tables['cloth'] priority = ['XXL', ' XL', ' L', ' S', ' M'] RowCount=table.RowCount rowsToInclude=IndexSet(RowCount,True) size = DataValueCursor.CreateFormatted(table.Columns["size"]) for item in priority: count = 0 for row in table.GetRows(rowsToInclude,size): rowIndex = row.Index if size.CurrentValue ==item: count += 1 if count == 1: ######### cursor = table.Select(" = " + item) table = Document.ActiveMarkingSelectionReference.SetSelection(cursor,table) break ######### else: if item == 'Z' and count > 1: ######### cursor = table.Select(" = ' '") table = Document.ActiveMarkingSelectionReference.SetSelection(cursor,table) ######### else: passSorry, I don't know how to use the documentation you recommend. But I just replace table=DataTableDataSource(table,cursor)with table = Document.ActiveMarkingSelectionReference.SetSelection(cursor,table). But no rows be selected. Is it still my syntax error or something else I don't know how to judge it. Can you tell me Thanks.
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