def tag_Marked_Items(tableName, colName, tagName): # Return: No return object(s) # Last updated: 6/30/18 # Created by: Tyler Hunt # # 1.0 - Create a reference to the targeted column # 2.0 - Creates a filter to only the marked row in the table # 3.0 - Finally, it tags the marked item(s) in the table # 3.1 - Tag the filtered data set with the # 3.2 - Print confirmation message(s) # 1.0 - Create reference to the tags column tagsCol = tableName.Columns[colName].As[TagsColumn]() # 2.0 - Get the marked rows filteringRowSelection = Document.ActiveMarkingSelectionReference.GetSelection( tableName) filteredSet = IndexSet(filteringRowSelection.AsIndexSet()) timeUpdated = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S") # 3.0 - Check if index set is empty if filteredSet.Count > 0: # 3.1 - Tag the filtered data set with the tagsCol.Tag(tagName, RowSelection(filteredSet)) # 3.2 - Print confirmation message print('Tag(s) have been created successfully @ ' + timeUpdated) else: # 3.2 - Print confirmation message print('No tag(s) have been created @ ' + timeUpdated)
def clear_Markings(markingName, tableName): # Return: No return object(s) # Last updated: 6/30/18 # Created by: Tyler Hunt # # 1.0 - Create reference to the markings # 2.0 - Create index set on the current table reference # 3.0 - Creates a cursor for the marked items in the table # 1.0 - Create reference to the markings marking = Application.GetService[DataManager]().Markings[markingName] # 2.0 - Create index set on the current table reference selectRows = IndexSet(tableName.RowCount, False) # 3.0 - Clar the markingon the table marking.SetSelection(RowSelection(selectRows), tableName) print('Marking(s) have been cleared')
def _delete_rows_(table, rowfilter, printstr='all rows'): """Deletes rows in a data table based on a filter args: table (Spotfire.table): table to delete from rowfilter (Spotfire.Dxp.Data.rowFilter): filter to delete with """ from Spotfire.Dxp.Data import RowSelection heading = "REMOVE ROWS" message = 'Deleting {} from table {}'.format(printstr, table.Name) confirmation = yes_no_message(message, heading) if confirmation: table.RemoveRows(RowSelection(rowfilter)) else: heading = 'User chickened out' message = 'You decided not to delete!' ok_message(message, heading)
from Spotfire.Dxp.Data import DataManager from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import RowSelection marking = Application.GetService[DataManager]().Markings[markingName] selectRows = IndexSet(dataTable.RowCount, False) marking.SetSelection(RowSelection(selectRows), dataTable)
#Laurent Cesaro #Import library from Spotfire.Dxp.Data import RowSelection, IndexSet selection = IndexSet(dt.RowCount, True) for r in selection: selection[r] = (r <= 100) #delete rows based on selection (rows from indexset marked as true) dt.RemoveRows(RowSelection(selection))
from Spotfire.Dxp.Data import DataColumn, TagsColumn from Spotfire.Dxp.Data import DataPropertyClass, DataType, DataValueCursor, IDataColumn, IndexSet from Spotfire.Dxp.Data import RowSelection # Tag the marked rows markedRowSelection = Document.ActiveMarkingSelectionReference.GetSelection( Document.ActiveDataTableReference) table = Document.ActiveDataTableReference myTagColumn = table.Columns.Item["Decision"].As[TagsColumn]() selectRows = IndexSet(table.RowCount, True) myTagColumn.Tag("No", RowSelection(selectRows)) myTagColumn.Tag("Yes", markedRowSelection)
def tag_bhaSelectedItems(columnName, tableName, bha_SelectedWells): # Return: list of bha's selected # Last updated: 6/30/18 # Created by: Tyler Hunt # # 1.0 - Create cursor to the bha selected marker # 2.0 - Create references to the bha table row count, rows to include and rows to mark # 3.0 - Loop thru the selected wells and add bhaSelected tag to wellsTable # 3.1 - Loop through the selcted well bha list # 3.2 - Loop through the wellsTable and mark the bha selected pn in wellsTable # 4.0 - Reference to the Tag Column # 5.0 - Get the marked rows # 5.1 - Tag the filtered data set with the # 5.2 - Print confirmation message(2) # 1.0 - Create cursor to the bha selected marker cursor_WellsPN = DataValueCursor.CreateFormatted( wellsTable.Columns['alt_well_pn']) # 2.0 - Create references to the bha table row count, rows to include and rows to mark rowCount = wellsTable.RowCount rowsToInclude = IndexSet(rowCount, True) rowsToMark = IndexSet(rowCount, False) # 3.0 - Loop thru the selected wells and add bhaSelected tag to wellsTable if not bha_SelectedWells: pass else: # 3.1 - Loop through the selcted well bha list for bhaPN in bha_SelectedWells: # 3.2 - Loop through the wellsTable and mark the bha selected pn in wellsTable for row in wellsTable.GetRows(cursor_WellsPN): rowIndex = row.Index wellsPN = cursor_WellsPN.CurrentValue # 3.3 - Mark well in wells table # TODO: Might need to check the Selcted status???? if wellsPN == bhaPN: rowsToMark.AddIndex(rowIndex) Document.ActiveMarkingSelectionReference.SetSelection( RowSelection(rowsToMark), wellsTable) # 4.0 - Reference to the Tag Column tagsCol = tableName.Columns[columnName].As[TagsColumn]() # Tag nname tagName = 'Selected' # Time updated timeUpdated = datetime.datetime.now().strftime("%m-%d-%Y %H:%M:%S") # 5.0 - Get the marked rows filteringRowSelection = Document.ActiveMarkingSelectionReference.GetSelection( tableName) filteredSet = IndexSet(filteringRowSelection.AsIndexSet()) # 5.0 - Check if index set is empty if filteredSet.Count != 0: # 5.1 - Tag the filtered data set with the tagsCol.Tag(tagName, RowSelection(filteredSet)) # 5.2 - Print confirmation message print('Bha Tag(s) have been created successfully @ ' + timeUpdated) else: # 5.2 - Print confirmation message print('No Bha tag(s) have been created @ ' + timeUpdated)