Wordwrap with long lines of text for a specific column
See original GitHub issueI have the following code:
results = [('test', 'PR skipped', '428 A PR from test to develop is already open. Please close/merge it before you run this script. And some more text.. Skipping this module...')]
headers=("Module Name", "Result", "Comment")
print(tabulate(results, headers, tablefmt="grid"))
and produces this
is there a way I can wrap text in the last column?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:10 (3 by maintainers)
Top Results From Across the Web
How can I wrap text at a certain column size?
What's the best way to force a text file with long lines to be wrapped at a certain width? Bonus points if you...
Read more >Wrap text in a cell - Microsoft Support
Microsoft Excel can wrap text so it appears on multiple lines in a cell. You can format the cell so the text wraps...
Read more >Wrapping Long Lines - jEdit
The word wrap feature splits lines at word boundaries in order to fit text within a specified wrap margin. A word boundary, for...
Read more >Wrapping and breaking text - CSS: Cascading Style Sheets
This property will break a word once it is too long to fit on a line by itself. Note: The overflow-wrap property acts...
Read more >datatable word wrap one columns to two lines - Stack Overflow
Im trying to give this row better styling, and one solution I thought of was to have the row wrap to two lines...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI, I had a need for this so have implemented most of this so far. Will plan on a PR in in the next few days. You’re welcome to look at it early if desired. https://github.com/astanin/python-tabulate/compare/master...magelisk:90-automatic-wordwrap?expand=1
It’s a feature I used to think about, and one day it may get implemented. Basically,
tabulate()
function will need an extra parameter with a list of column widths. Something like this:Meanwhile this effect can be easily achieved by using
textwrap
module directly, which is part of the standard library. It is as easy as writing two lines of code if you want to wrap all columns:And the result is what you want:
You get the idea.