Selected Rows¶
Each TableSheet has a set of selected rows, which is a strict subset of the rows on the sheet.
- TableSheet.selectedRows¶
List of selected rows in sheet order.
- TableSheet.someSelectedRows¶
Return a list of rows: (a) in batch mode, always return selectedRows (b) in interactive mode, if options.some_selected_rows is True, return selectedRows or all rows if none selected (c) in interactive mode, if options.some_selected_rows is False, return selectedRows or fail if none selected
Changed in version 2.1.
- TableSheet.onlySelectedRows¶
List of selected rows in sheet order. Fail if no rows are selected.
Changed in version 2.1.
- TableSheet.nSelectedRows¶
Number of selected rows.
- visidata.TableSheet.selectRow(self, row)¶
Add row to set of selected rows. May be called multiple times in one command. Overridable.
- visidata.TableSheet.unselectRow(self, row)¶
Remove row from set of selected rows. Return True if row was previously selected. Overridable.
- visidata.TableSheet.isSelected(self, row)¶
Return True if row is selected.
- visidata.TableSheet.clearSelected(self)¶
Clear set of selected rows, without calling
unselectRow
for each one.
- visidata.TableSheet.selectByIdx(self, rowIdxs)¶
Add rows indicated by row indexes in rowIdxs to set of selected rows. Async.
- visidata.TableSheet.unselectByIdx(self, rowIdxs)¶
Remove rows indicated by row indexes in rowIdxs from set of selected rows. Async.
- visidata.TableSheet.select(self, rows, status=True, progress=True, add_undo=True)¶
Add rows to set of selected rows. Async. Don’t show progress if progress is False; don’t show status if status is False. If add_undo is False, do not add an undo selection function to the undo history; useful for lowering memory consumption when caller is changing a large batch of selects in one command.
- visidata.TableSheet.unselect(self, rows, status=True, progress=True, add_undo=True)¶
Remove rows from set of selected rows. Async. Don’t show progress if progress is False; don’t show status if status is False. If add_undo is False, do not add an undo unselection function to the undo history; useful for lowering memory consumption when caller is changing a large batch of selects in one command.
- visidata.TableSheet.deleteSelected(self)¶
Delete all selected rows. Async.
Note
To clear the set of selected rows before any bulk selection, set options.bulk_select_clear
to True.
The status message will include “instead” as a reminder that the option is enabled.
Warning
selectedRows
feels like a list, but it’s actually a property that iterates over all rows to generate the selected rows in sheet order.
With large datasets, collecting the list of selected rows itself can take a large time, regardless of the number of rows that are actually selected.
So instead of using selectedRows in the execstr, call an @asyncthread
@TableSheet.api
function which uses sheet.selectedRows.
Use it as a parameter immediately or save it to a local variable on the first usage, to avoid unnecessary work.
Sorting¶
- visidata.TableSheet.orderBy(sheet, *cols, reverse=False, change_column=False, save_cmd_input=True)¶
Add cols to internal ordering and re-sort the rows accordingly. Pass reverse as True to order these cols descending. Pass empty cols (or cols[0] of None) to clear internal ordering. Set change_column to True to change the sort status of a single column: add/remove/invert it. When changing a column, cols must have length 1. Sort columns that had higher priority are unchanged. Lower-priority columns are removed. If change_column is False, cols will be added to the existing ordering. If save_cmd_input is True, the full ordering that results will be saved in the cmdlog for future replay in the ‘input’ parameter.
- visidata.TableSheet.sort(self)¶
Sort rows according to the current internal ordering.