Skip to content

Is there any way to select the n rows preceding (or following) the selected ones? #2644

Answered by midichef
aborruso asked this question in Q&A
Discussion options

You must be logged in to vote

There's no ready-made command, but you can do it with a few lines in your .visidatarc:

@Sheet.api
def select_before_after(sheet, n_before, n_after):
    sheet.select(list(itertools.chain(*(winrows for row, winrows in sheet.window(int(n_before), int(n_after)) if sheet.isSelected(row)))))
Sheet.addCommand('', 'select-before-n', 'select_before_after(input("select rows before selected: ", value=1), 0)', 'select additional N rows before/after each selected row')
Sheet.addCommand('', 'select-after-n', 'select_before_after(0, input("select rows after selected: ", value=1))', 'select additional N rows before/after each selected row')

@saulpw @anjakefala should this be a feature?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aborruso
Comment options

Answer selected by aborruso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants