From 7058454bd9f24be0583baa40b2595502ca62147a Mon Sep 17 00:00:00 2001 From: midichef <67946319+midichef@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:49:57 -0800 Subject: [PATCH 1/2] [join-] fix putValue for merge rows absent in any source sheet --- visidata/features/join.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/visidata/features/join.py b/visidata/features/join.py index bde9ed876..603926eeb 100644 --- a/visidata/features/join.py +++ b/visidata/features/join.py @@ -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] From 282a7a389b7b6ff4487f2e34801aa6e2a474d482 Mon Sep 17 00:00:00 2001 From: anjakefala Date: Fri, 3 Jan 2025 22:52:24 -0800 Subject: [PATCH 2/2] [tests-] test putValue for merged row when source row is missing #2647 --- sample_data/a.tsv | 3 +++ sample_data/b.tsv | 3 +++ tests/golden/pr2647.tsv | 4 ++++ tests/pr2647.vdj | 10 ++++++++++ 4 files changed, 20 insertions(+) create mode 100644 sample_data/a.tsv create mode 100644 sample_data/b.tsv create mode 100644 tests/golden/pr2647.tsv create mode 100644 tests/pr2647.vdj diff --git a/sample_data/a.tsv b/sample_data/a.tsv new file mode 100644 index 000000000..098281b47 --- /dev/null +++ b/sample_data/a.tsv @@ -0,0 +1,3 @@ +key source_sheet +a_only a +both a diff --git a/sample_data/b.tsv b/sample_data/b.tsv new file mode 100644 index 000000000..e0a68d9a5 --- /dev/null +++ b/sample_data/b.tsv @@ -0,0 +1,3 @@ +key source_sheet +b_only b +both b diff --git a/tests/golden/pr2647.tsv b/tests/golden/pr2647.tsv new file mode 100644 index 000000000..0e3b2136f --- /dev/null +++ b/tests/golden/pr2647.tsv @@ -0,0 +1,4 @@ +key source_sheet +b_only c +both a +a_only a diff --git a/tests/pr2647.vdj b/tests/pr2647.vdj new file mode 100644 index 000000000..c97aa6049 --- /dev/null +++ b/tests/pr2647.vdj @@ -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}