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

[html] fix failure from colspan with only td tags #2002

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Aug 19, 2023

When an HTML table has colspan, with only td tags, the visidata rows contain invalid data for the resulting empty cells, and the table can't be viewed.

More specifically, cells in a row created by the html loader should be tuples like (cellval, links):

row[colnum] = (cellval, links)

But for empty cells, what iterload() adds to the row is a None object, not a tuple. That causes the following exception that makes the table unviewable:

Traceback (most recent call last):
  File "/home/j/.local/lib/python3.10/site-packages/visidata/threads.py", line 200, in _toplevelTryFunc
    t.status = func(*args, **kwargs)
  File "/home/j/.local/lib/python3.10/site-packages/visidata/sheets.py", line 235, in reload
    for r in self.iterload():
  File "/home/j/.local/lib/python3.10/site-packages/visidata/loaders/html.py", line 160, in iterload
    it = list(list(x) for x in self.rows.pop(0))
  File "/home/j/.local/lib/python3.10/site-packages/visidata/loaders/html.py", line 160, in <genexpr>
    it = list(list(x) for x in self.rows.pop(0))
TypeError: 'NoneType' object is not iterable

Here is an example file to reproduce the error: td_colspan.html.txt
It can be viewed with vd -f html td_colspan.html.txt

This PR fixes that issue and allows the table to be viewed.

The resulting table will still show errors for the empty cells, which I did not attempt to fix. They are the same errors already covered by #1308 , but caused by colspan instead of the rowspan that the open issue discusses.

@saulpw
Copy link
Owner

saulpw commented Aug 21, 2023

Thanks @midichef for catching this oversight!

@saulpw saulpw merged commit 570e5da into saulpw:develop Aug 21, 2023
@midichef midichef deleted the html_td_colspan branch November 16, 2023 05:57
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.

2 participants