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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Dec 21, 2024

When editing cells in a MergeColumn, an error will occur if the row is absent from any of the source sheets. putValue() will attempt to set the value on the source sheet that does not have the row, causing an error:

  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/features/join.py", line 169, in putValue
    c.setValue(row[vs], value)
...
  File "/home/midichef/.venv/lib/python3.12/site-packages/visidata/utils.py", line 73, in setitem
    r[i] = v
TypeError: 'NoneType' object does not support item assignment

To reproduce this, unzip merge_rows.zip, and do vd -p test.vdj
Then edit cells in the source_sheet column. The cell with source_sheet of b will have the error after you try to edit it with e and enter any value. The cell for the a_only row will also give the error, though the edit will succeed.

This PR adds a check similar to the one in JoinKeyColumn:

if row[c.sheet] is not None:
c.setValues([row[c.sheet]], value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant