Using prettytables with Pluto

Thanks Clark and Rob! I think it is getting closer. What I am ultimately trying to do is print out the table in both REPL and Pluto. The printout in both cases will look similar to DataFrame(chunks).

@goedman, I tried your code but there were a few problems. Although it now prints out a table with the ability to expand the view, it does not have labels or the correct number of columns. There should be 12 columns instead of 8.

As a point of reference, here is what it looks like in the REPL. I was hoping for something similar in Pluto. I’m still trying different suggestions, but nothing is quite working.

Here is what Pluto currently displays:

As you can see, it is missing columns and column labels.

Yip, we want all the features but don’t wanna wait 1s for DataFrames to load :slight_smile:

1 Like

Did this ever get finalized? I would like to display tables in a Pluto notebook and while pretty_tables lets me pick various backends, they don’t display as a Pluto object.

Something like

pretty_table(HTML, rand(4, 2))

works for me:

1 Like

pretty_table(HTML, …) looks much nicer in Pluto than pretty_table(…) which (I think) defaults to the text backend. However, unlike the text backend, pretty_table(HTML,…) shows the entire table rather than having a vertical scrollbar for tables with many rows. Is there an override for this default, i.e. can one have the better looking display of the HTML backend and still have a scrollable display?

for others who are interested in this: i found a way but it’s ugly. i’m hoping someone can point out an argument to pretty_table that i’m unaware of.

here’s my ugly solution for pretty printing dataframe df in Pluto:

using HypertextLiteral, PrettyTables
html_table = pretty_table(String, df, backend = Val(:html),formatters =...)
scrollable_table = @htl("""
    <div style="max-height: 400px; overflow-y: auto; border: 1px solid #ccc;">
        $(HTML(html_table))
    </div>
""")
scrollable_table

as a further addendum: it would be great to have the column headers remain visible while scrolling down in either the text or html backends. is that possible?

1 Like