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 rows to set of selected rows. Async. Don’t show progress if progress is False; don’t show status if status is False.

visidata.TableSheet.unselect(self, rows, status=True, progress=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.

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)

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.

visidata.TableSheet.sort(self)

Sort rows according to the current internal ordering.