Tim McCune 3 Posted May 13, 2019 Share Posted May 13, 2019 I want to use the AddRows(DataSource, AddRowsSettings) operation on a DataTable but I want to be able to specify which rows from the DataSource should be added using an index range. Is this possible This is what I currently have: from Spotfire.Dxp.Data import * from Spotfire.Dxp.Data.Import import DataTableDataSource inputTableDS = DataTableDataSource(Document.Data.Tables["Table1") outputTable = Document.Data.Tables["Table2"] addRowsSettings = AddRowsSettings(outputTable, inputTableDS, "Source", "Table2", "Table1") outputTable.AddRows(inputTableDS, addRowsSettings) I'm just not sure how to specify that I only want to add the 1st 10 rows from "Table1", for example. Link to comment Share on other sites More sharing options...
Khushboo Rabadia Posted May 16, 2019 Share Posted May 16, 2019 (edited) You can get the rowSelection by applying desired limit but then there is no way to add rows from that rowselection to another table directly, as for adding new rows you will need DataSelection object. I used this workaround: 1) Create a dummy marking say TestMarking 2) Then execute below script which will set thatsubset of rows as marked in TestMarking and then pass TestMarking DataSelection to DataTableDataSource method from Spotfire.Dxp.Data import * from Spotfire.Dxp.Data.Import import * #Source Data Table TableB="World Bank Data" sourceDataTable=Document.Data.Tables[TableB] dt2=sourceDataTable.Select("[Country Code] = 'ABW'") #Suppose need only data for country code ABW in new table marking=Document.Data.Markings["TestMarking"].SetSelection(dt2, sourceDataTable) dataselection=Document.Data.Markings["TestMarking"] dataSource=DataTableDataSource(sourceDataTable,dataselection) #Append rows to new data table destinationDataTable=Document.Data.Tables["TableA"] rowsettings=AddRowsSettings(destinationDataTable,dataSource) destinationDataTable.AddRows(dataSource,rowsettings) Edited June 14 by Jose Leviaguirre Link to comment Share on other sites More sharing options...
Tim McCune 3 Posted May 16, 2019 Author Share Posted May 16, 2019 This is great, thanks Khushboo! Link to comment Share on other sites More sharing options...
Anders Gavare Posted May 21, 2019 Share Posted May 21, 2019 You may want to use a "Filter Rows" transformation on the data source that you are adding. More info about the transformation can be found here:https://docs.tibco.com/pub/sfire-analyst/10.1.0/doc/html/en-US/TIB_sfire-analyst_UsersGuide/data/data_details_on_filter_rows.htm and how to use it programmatically here:https://docs.tibco.com/pub/doc_remote/sfire-analyst/10.3.0/doc/api/html/T_Spotfire_Dxp_Data_Transformations_FilterRowsTransformation.htm The expression to use as filter could then be something like: rowid() Link to comment Share on other sites More sharing options...
Tim McCune 3 Posted May 21, 2019 Author Share Posted May 21, 2019 That's great, thanks for the help! 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