# Pretty printing of tables

**URL:** https://discourse.julialang.org/t/pretty-printing-of-tables/7254
**Category:** Data
**Created:** [November 22, 2017, 6:50pm UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254 "2017-11-22T18:50:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Rafal\_Machalica](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafal_machalica/32/8207_2.png) [@Rafal\_Machalica](https://discourse.julialang.org/u/Rafal_Machalica)
#### Post date: [November 22, 2017, 6:50pm UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/1 "2017-11-22T18:50:35Z")

</div>

I’m looking for a quick solution of printing human-readable 2D tables. I thought I found a solution - NamedArrays. It meets my needs in terms of formatting, however when the table is slightly bigger (but still could fit into standard terminal window) it gets “compressed”, i.e. it shows only first two and last two columns and in-between columns are replaced with three dots “…” symbol. I tried “showall” function, but it still shows compressed version. Is there any possibility to force full print of NamedArray? Or is there any other data structure that meets requirement of “pretty printing of full data”?

I do realize that I can print iteratively every element of the array and I already had it implemented (very primitively), but I’m looking for some more user-friendly solution.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [November 22, 2017, 11:32pm UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/2 "2017-11-22T23:32:11Z")

</div>

> [@Rafal\_Machalica](#):
>
> Is there any possibility to force full print of NamedArray?

It looks like NamedArrays is missing a check for the `limit` property of the IO context: [Check get(io, :limit, true) in show · Issue #56 · davidavdav/NamedArrays.jl · GitHub](https://github.com/davidavdav/NamedArrays.jl/issues/56)

Until then, you should be able to do

```jl
show(IOContext(STDOUT, :displaysize=>(10^6,10^6)), "text/plain", a)

```

to trick the `show` function into displaying the whole array `a` by telling it that the display size is huge.

---

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [November 23, 2017, 1:12am UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/3 "2017-11-23T01:12:09Z")

</div>

You might also want to try constructing `Markdown` tables, which render nicely in a variety of output modes.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 23, 2017, 7:26am UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/4 "2017-11-23T07:26:22Z")

</div>

I have a trivial package that basically stores the strings you throw at it with their alignment, then when you are done it prints them padded with spaces:  
[https://github.com/tpapp/AutoAligns.jl](https://github.com/tpapp/AutoAligns.jl)

---

<div class="post-metadata">

### Author: ![Rafal\_Machalica](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafal_machalica/32/8207_2.png) [@Rafal\_Machalica](https://discourse.julialang.org/u/Rafal_Machalica)
#### Post date: [November 23, 2017, 4:58pm UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/5 "2017-11-23T16:58:47Z")

</div>

OK. The trick with bigger displaysize solved my problem for now. I will also review the other methods (Markdown and AutoAligns) as they look promissing for more advanced use cases.

Thanks for all the hints!

---

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [November 25, 2017, 9:48am UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/6 "2017-11-25T09:48:13Z")

</div>

Is this relevant at all?

> [@Best tool for printing tables in Jupyter notebook?](https://discourse.julialang.org/t/best-tool-for-printing-tables-in-jupyter-notebook/3548/8):
>
> I wrote this up. It’s basically just @cstjean’s code from above: There’s probably more to be done on it module HTMLElements export table function table(cur\_matrix::Matrix; header\_row=[], title=nothing) cur\_table = "" if title != nothing cur\_table \*= "\<h2 style='padding: 10px'\>$title\</h2\>" end cur\_table \*= "\<table class='table table-striped'\>" if !isempty(header\_row) cur\_table \*= "\<thead\>\<tr\>" for cur\_header in header\_row cur\_table \*= "\<t…

* * *

an example table i made in a jupyter notebook (w/ interact):

 ![59 AM](https://global.discourse-cdn.com/julialang/original/3X/c/c/ccc2490dc2c972e77a860049981189708712b160.png)

---

<div class="post-metadata">

### Author: ![Rafal\_Machalica](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafal_machalica/32/8207_2.png) [@Rafal\_Machalica](https://discourse.julialang.org/u/Rafal_Machalica)
#### Post date: [November 25, 2017, 10:53pm UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/7 "2017-11-25T22:53:56Z")

</div>

So many options to choose from. I will have to study them more in depth for effective use. I will also keep track of development progress of these tools and see which one becomes more like a common “standard” in the ecosystem.

---

<div class="post-metadata">

### Author: ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)
#### Post date: [November 26, 2017, 12:06am UTC](https://discourse.julialang.org/t/pretty-printing-of-tables/7254/8 "2017-11-26T00:06:09Z")

</div>

Hi Rafal,

My bad. The code below also has support for passing css classes

// that’s how I made the cells (above): `red`, `blue`, `green` & `yellow`

[https://github.com/djsegal/Fusion.jl/blob/2cde77e2422dce590e770d2937a444c1eabfea7a/src/modules/HTMLElements.jl](https://github.com/djsegal/Fusion.jl/blob/2cde77e2422dce590e770d2937a444c1eabfea7a/src/modules/HTMLElements.jl)
