python-tabulate icon indicating copy to clipboard operation
python-tabulate copied to clipboard

maxcolwidths is broken with fancy_outline

Open yurivict opened this issue 1 year ago • 4 comments

This testcase:

from tabulate import tabulate

headers = ['Header#1', 'Header#2', 'Header#3']
data = []
data.append(['Alpha beta gama zeta omega', 'The weather was exceptionally good that day again', 'The files were concatenated and archived for posterity.'])
data.append(['Delta omega beta alpha nu and the rest', 'The weather was exceptionally good that day', 'They decided to engage in many businesses and all of them were successful.'])

print(tabulate(
    data,
    headers=headers,
    tablefmt='fancy_outline',
    maxcolwidths=[None, None, 8]))

produces this output:

╒════════════════════════════════════════╤═══════════════════════════════════════════════════╤═══════════════════════════════════════════════════════════════════════════════╕
│ Header#1                               │ Header#2                                          │ Header#3                                                                      │
╞════════════════════════════════════════╪═══════════════════════════════════════════════════╪═══════════════════════════════════════════════════════════════════════════════╡
│ Alpha beta gama zeta omega             │ The weather was exceptionally good that day again │ The
files
were con
catenate
d and
archived
for post
erity.                    │
│ Delta omega beta alpha nu and the rest │ The weather was exceptionally good that day       │ They
decided
to
engage
in many 
business
es and
all of
them
were suc
cessful. │
╘════════════════════════════════════════╧═══════════════════════════════════════════════════╧═══════════════════════════════════════════════════════════════════════════════╛

yurivict avatar Nov 14 '24 20:11 yurivict

The same is true with github formatting.

rubyff avatar Mar 26 '25 13:03 rubyff

For me it seems that fancy_outline works well:

╒════════════════════════════════════════╤═══════════════════════════════════════════════════╤════════════╕
│ Header#1                               │ Header#2                                          │ Header#3   │
╞════════════════════════════════════════╪═══════════════════════════════════════════════════╪════════════╡
│ Alpha beta gama zeta omega             │ The weather was exceptionally good that day again │ The        │
│                                        │                                                   │ files      │
│                                        │                                                   │ were con   │
│                                        │                                                   │ catenate   │
│                                        │                                                   │ d and      │
│                                        │                                                   │ archived   │
│                                        │                                                   │ for post   │
│                                        │                                                   │ erity.     │
│ Delta omega beta alpha nu and the rest │ The weather was exceptionally good that day       │ They       │
│                                        │                                                   │ decided    │
│                                        │                                                   │ to         │
│                                        │                                                   │ engage     │
│                                        │                                                   │ in many    │
│                                        │                                                   │ business   │
│                                        │                                                   │ es and     │
│                                        │                                                   │ all of     │
│                                        │                                                   │ them       │
│                                        │                                                   │ were suc   │
│                                        │                                                   │ cessful.   │
╘════════════════════════════════════════╧═══════════════════════════════════════════════════╧════════════╛

But github tablefmt still has broken.

CodeGenerator avatar May 02 '25 19:05 CodeGenerator

Fixed github format https://github.com/astanin/python-tabulate/pull/366

CodeGenerator avatar May 06 '25 12:05 CodeGenerator

@yurivict @rubyff Which versions of python-tabulate are you using?

>>> from tabulate import tabulate
>>>
>>> headers = ['Header#1', 'Header#2', 'Header#3']
>>> data = [
...     ['Alpha beta gama zeta omega', 'The weather was exceptionally good that day again', 'The files were concatenated and archived for posterity.'],
...     ['Delta omega beta alpha nu and the rest', 'The weather was exceptionally good that day', 'They decided to engag e in many businesses and all of them were successful.'],
... ]
>>>
>>> print(tabulate(
...     data,
...     headers=headers,
...     tablefmt='fancy_outline',
...     maxcolwidths=[None, None, 8],
... ))
╒════════════════════════════════════════╤═══════════════════════════════════════════════════╤════════════╕
│ Header#1                               │ Header#2                                          │ Header#3   │
╞════════════════════════════════════════╪═══════════════════════════════════════════════════╪════════════╡
│ Alpha beta gama zeta omega             │ The weather was exceptionally good that day again │ The        │
│                                        │                                                   │ files      │
│                                        │                                                   │ were con   │
│                                        │                                                   │ catenate   │
│                                        │                                                   │ d and      │
│                                        │                                                   │ archived   │
│                                        │                                                   │ for post   │
│                                        │                                                   │ erity.     │
│ Delta omega beta alpha nu and the rest │ The weather was exceptionally good that day       │ They       │
│                                        │                                                   │ decided    │
│                                        │                                                   │ to engag   │
│                                        │                                                   │ e in       │
│                                        │                                                   │ many bus   │
│                                        │                                                   │ inesses    │
│                                        │                                                   │ and all    │
│                                        │                                                   │ of them    │
│                                        │                                                   │ were suc   │
│                                        │                                                   │ cessful.   │
╘════════════════════════════════════════╧═══════════════════════════════════════════════════╧════════════╛
>>> 

DimitriPapadopoulos avatar Sep 13 '25 14:09 DimitriPapadopoulos