This is not ideal, but I think you can tweak the following code to meet your needs:
function dfshow(df, num_printed_rows, max_str)
rows, cols = size(df)
display_rows, display_cols = displaysize(stdout)
# Compute the size of the `Row` column.
row_size = floor(Int, log10(rows)) + 1 + 2
num_cols_per_line = floor(Int, (display_cols - row_size)/(max_str+2))
num_cols_per_line == 0 && (num_cols_per_line = 1)
col_beg = 1
col_end = clamp(num_cols_per_line, 0, cols)
while true
show(view(df, :, col_beg:col_end),
truncate = max_str,
display_size = (num_printed_rows + 8, display_cols))
println()
col_beg = col_end + 1
col_end == cols && break
col_end = clamp(col_end + num_cols_per_line, 0, cols)
end
end
Just three notes:
- There is probably 100 ways to write a better code than I did
- The complicated part is to compute the size of the printed table. I think I need to add a function in PrettyTables to return such sizes. It will help a lot.
- If the column width is lower than
max_str
, then there will be a lot of empty space in the line.