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

Table rendering throws ValueError (invalid width) for tables wider than screen #88

Open
vduseev opened this issue Sep 25, 2020 · 0 comments
Milestone

Comments

@vduseev
Copy link

vduseev commented Sep 25, 2020

Summary

When we try to render a table that does not fit into a screen width (terminal width) a ValueError is thrown.

What happens

In the example below I have a table with 42 columns which is approximately 4x times wider than terminal's screen allows.

self.render_table(headers, rows)

ValueError

  invalid width -9 (must be > 0)

  at /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/textwrap.py:248 in _wrap_chunks
      244lines, but apart from that whitespace is preserved.
      245│         """
      246│         lines = []
      247│         if self.width <= 0:
    → 248│             raise ValueError("invalid width %r (must be > 0)" % self.width)
      249if self.max_lines is not None:
      250if self.max_lines > 1:
      251indent = self.subsequent_indent
      252else:

What's expected

Either table is shrinked into given width or is rendered despite not fitting into the screen. Both options look ugly as hell though. More options are below

Fix suggestions

A. Fit table into terminal despite ugly outcome
B. Draw table wider than terminal despite ugly outcome
C. Somehow smartly draw the table in such a way that too long content becomes multi-line (already implemented somewhat). Also issue #47 talks about that option.
D. Add option to transpose table when redered (like \x flag does in PostgreSQL's psql command line tool)
E. Add option to break table into multiple pages where each page fits into screen

@Secrus Secrus added this to the Future milestone Sep 5, 2022
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

No branches or pull requests

2 participants