After developing PrettyTables.jl, I understood how hard is to design cropping mechanism to show large data into the terminal. We did have a “nice” algorithm, but with some caveats. For example, it is not that easy to crop the table in the middle of the columns. Thus, PrettyTables.jl always crop columns at the end.
Recently, there was a request on Slack (Jerry Ling) to add a way to break the table, printing the columns that does not fit sequentially. However, it would be very, very difficult to do due to corner cases.
That’s why I decided to make a small package trying to replicate the command less. This is 100% written in Julia and should work in all platforms (at least in terminals that support the standard escape sequences).
This new package is called TerminalPager.jl and should fix those problems letting the user to scroll through the table:
Done, everything is fine now. Thank everyone for the suggestions! The package should be merged in three days. If anyone wants to test it before, just do:
julia>]add https://github.com/ronisbr/TerminalPager.jl
julia> using TerminalPager
julia> rand(10,100) |> TerminalPager.less
P.S.: I tested in Windows 10. It seems to work but with terrible performance. However, it could be caused by the virtual machine I was using. Feedback is appreciated!
Wow this is great. Very often I find myself needing View(df) from R which pop’s up the Table in a GUI/cell format. This is a good replacement in Julia REPL. Could it be possible to add a GUI/HTML so it can also work like R’s View(df)?
Thanks! I think it is better to keep this package to terminal only. My plan is to add it as a dependency of PrettyTables.jl to help showing large data. Hence, if we add a lot of things, then the loading time can be bad. However, we can create another package, something like GraphicalPager / Viewer or something.
The problem is that for GUI you need to find a good toolkit that can easily work along all the platforms. This can be challenging and, unfortunately, I do not have much expertise (creating GUIs using Julia).
An awesome use for this pacakge would be for long docstrings. I’ve often wanted ? pretty_table or ? transform to be in a scrollable thing that doesn’t clutter my REPL.
Nice! Good to know, I do not have any linux machine right now to test. Thanks for letting me know.
The pager does not add any content to the string. This information comes from DataFrames.
Hum, we will have a lot of problems with those key codes. This can be related to VS code terminal not passing the correct escape codes for some reason. Can you test in a terminal please?
Thanks! Let’s hope it can be useful
That’s the idea! Add this package as a dependency to PrettyTables and have an option crop = :less or something.