question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

Multi-line text within a cell does not format well with _outline formatting

See original GitHub issue

I am working on printing output that sometimes have multiline entries in a cell. I like the *_outline tblfmtโ€™s and am wondering if the format can be adapted to fix formatting with multilines

tabulate version 0.9.0

Code

import tabulate as tb
from tabulate import tabulate
print(tb.__version__)
header = ['A', 'B', 'C', 'D']
row1 = [
    '1', '2', '3', '4'
]

row2 = [
    '5', '6', '7', '8\n88'
]

row3 = [
    '9', '10', '11', '12'
]
table_body = []
table_body.append(row1)
table_body.append(row2)
table_body.append(row3)
print(tabulate(table_body, headers=header))
print(tabulate(table_body, headers=header, tablefmt='pretty'))
print(tabulate(table_body, headers=header, tablefmt='simple_outline'))
print(tabulate(table_body, headers=header, tablefmt='rounded_outline'))

Output:

0.9.0
  A    B    C  D
---  ---  ---  ---
  1    2    3  4
  5    6    7  8
               88
  9   10   11  12
+---+----+----+----+
| A | B  | C  | D  |
+---+----+----+----+
| 1 | 2  | 3  | 4  |
| 5 | 6  | 7  | 8  |
|   |    |    | 88 |
| 9 | 10 | 11 | 12 |
+---+----+----+----+
โ”Œโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   A โ”‚   B โ”‚   C โ”‚ D    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   1 โ”‚   2 โ”‚   3 โ”‚ 4    โ”‚
โ”‚   5 โ”‚   6 โ”‚   7 โ”‚ 8
88 โ”‚
โ”‚   9 โ”‚  10 โ”‚  11 โ”‚ 12   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ•ญโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚   A โ”‚   B โ”‚   C โ”‚ D    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   1 โ”‚   2 โ”‚   3 โ”‚ 4    โ”‚
โ”‚   5 โ”‚   6 โ”‚   7 โ”‚ 8
88 โ”‚
โ”‚   9 โ”‚  10 โ”‚  11 โ”‚ 12   โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
eliegoudoutcommented, Nov 30, 2022

The file you downloaded is the right one. Can you check the help of tabulate once youโ€™ve imported it?

>>> help(tabulate)
Help on function tabulate in module MyPackages.tabulate:

tabulate(tabular_data, headers=(), tablefmt='simple', floatfmt='g', intfmt='', numalign='default', stralign='default', missingval='', showindex='default', disable_numparse=False, colglobalalign=None, colalign=None, maxcolwidths=None, headersglobalalign=None, headersalign=None, rowalign=None, maxheadercolwidths=None)

Just to be sure you imported from the right file.

1reaction
networkprogrammercommented, Nov 30, 2022

OK, so that worked. This line from your output gave me the idea on how to do it. >>> from MyPackages.tabulate import tabulate

Thank you, that PR does fix the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel Tips 31 - Add Multiple Lines to Text within Cells - YouTube
This allows you to have paragraph style formatting for text within a cell whereby you can enter text on lines below other text...
Read more >
How to Make Multiple Lines in Excel Cell - Excelchat - Got It AI
Formatting Cell as Wrap Text ยท Select the cells having long text ยท On the Home tab, in the Alignment group select the...
Read more >
How to copy multi-line text from Excel without quotes?
(The blue outlines.) Paste Special Options. To get unformatted text in Word without the double quotes: Paste the text in formatted so it...
Read more >
Excel format for number, text, scientific notation, accounting, etc.
The tutorial explains the basics of Excel format for number, text, currency, percentage, accounting number, scientific notation, and more.
Read more >
How to put multiple lines into cells in Microsoft Excel
Just go to the Home tab and click on Wrap Text: Good news: You can apply this formatting to more than one cell...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found