Pretty printing of tables

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.

1 Like

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

Until then, you should be able to do

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.

1 Like

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

1 Like

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

4 Likes

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!

Is this relevant at all?


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

1 Like

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.

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