Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[join-] fix putValue for merge rows absent in any source sheet #2647

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sample_data/a.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
key source_sheet
a_only a
both a
3 changes: 3 additions & 0 deletions sample_data/b.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
key source_sheet
b_only b
both b
4 changes: 4 additions & 0 deletions tests/golden/pr2647.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
key source_sheet
b_only c
both a
a_only a
10 changes: 10 additions & 0 deletions tests/pr2647.vdj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!vd -p
{"sheet": null, "col": "", "row": "", "longname": "open-file", "input": "sample_data/a.tsv", "keystrokes": "o", "comment": null, "replayable": true}
{"col": "", "row": "", "longname": "open-file", "input": "sample_data/b.tsv", "keystrokes": "o", "replayable": true}
{"sheet": "a", "col": "key", "row": "", "longname": "key-col", "input": "", "keystrokes": "!", "comment": "toggle current column as a key column", "replayable": true}
{"sheet": "b", "col": "key", "row": "", "longname": "key-col", "input": "", "keystrokes": "!", "comment": "toggle current column as a key column", "replayable": true}
{"sheet": "b", "col": "", "row": "", "longname": "sheets-stack", "input": "", "keystrokes": "Shift+S", "comment": "open Sheets Stack: join or jump between the active sheets on the current stack", "replayable": true}
{"sheet": "sheets", "col": "", "row": 1, "longname": "stoggle-row", "input": "", "keystrokes": "t", "comment": "toggle selection of current row", "replayable": true}
{"sheet": "sheets", "col": "", "row": 2, "longname": "stoggle-row", "input": "", "keystrokes": "t", "comment": "toggle selection of current row", "replayable": true}
{"sheet": "sheets", "col": "", "row": "", "longname": "join-selected", "input": "merge", "keystrokes": "&", "comment": "merge selected sheets with visible columns from all, keeping rows according to jointype", "replayable": true}
{"sheet": "b+a", "col": "source_sheet", "row": 0, "longname": "edit-cell", "input": "c", "keystrokes": "e", "comment": "edit contents of current cell", "replayable": true}
3 changes: 2 additions & 1 deletion visidata/features/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def calcValue(self, row):

def putValue(self, row, value):
for vs, c in reversed(list(self.cols.items())):
c.setValue(row[vs], value)
if row[vs] is not None:
c.setValue(row[vs], value)

def isDiff(self, row, value):
col = list(self.cols.values())[0]
Expand Down
Loading