Pretty printing of tables


#1

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.


ANN: RegressionTables.jl produces publication-quality regression tables
Markdown tables
#2

It looks like NamedArrays is missing a check for the limit property of the IO context: https://github.com/davidavdav/NamedArrays.jl/issues/56

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.


#3

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


#4

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:


#5

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!


#6

Is this relevant at all?


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


#7

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.


#8

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