-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting maximum column width #21
Comments
Hi @darrencl , Sorry for the late response, it was a very busy week. I really like your suggestion. I will split this into two parts: it is easy to create the cropping based on the maximum column width. However, the automatic line break needs more thinking. We can split in the closest whitespace (adding |
Hi @ronisbr No worries at all! Thanks for getting back to this. I agree on splitting this into 2 parts given the latter feature, I think, is more of 'nice to have'. Yeah, I was thinking the same on splitting the string into closest whitespace and maybe adding spaces if the number of character is less than the max (with this, every line will have same number of characters). If I understand the default behavior correctly, this will ensure every columns have the same width. In regards to the issues on |
The keyword `columns_width` can be used to specify the desired width for each column. This addresses the first part of issue #21.
Hi @darrencl , If you use julia> model = [1.123456789 for i = 1:8, j = 1:10];
julia> pretty_table(model; columns_width = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9])
┌───┬─────────────┬────┬─────┬──────┬───────┬────────┬─────────┬──────────┬───────────┐
│ … │ Col. 2 │ C… │ Co… │ Col… │ Col.… │ Col. 7 │ Col. 8 │ Col. 9 │ Col. 10 │
├───┼─────────────┼────┼─────┼──────┼───────┼────────┼─────────┼──────────┼───────────┤
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
│ … │ 1.123456789 │ 1… │ 1.… │ 1.1… │ 1.12… │ 1.123… │ 1.1234… │ 1.12345… │ 1.123456… │
└───┴─────────────┴────┴─────┴──────┴───────┴────────┴─────────┴──────────┴───────────┘ |
Hi @ronisbr , Sorry for the late reply, was busy yesterday. I think an option to input |
Nice! The idea of an |
What do you think about removing the possibility to be |
I think it is not a big deal since the automatic size is the default behaviour. :) |
If `columns_width` is an integer, then it will be the size of all columns. This addresses part of issue #21.
Done! julia> model = [1.123456789 for i = 1:8, j = 1:10];
julia> pretty_table(model; columns_width = 5)
┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐
│ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │ Col.… │
├───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
│ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │ 1.12… │
└───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘ |
Hi @darrencl ! Finally, I could finish the code to auto wrap the text on spaces. Can you please test to me? Is it available in
|
In fact I just found a bug :D |
Now its fine :)
|
@ronisbr Very nice! Thanks for the update! |
Hi @jo-fleck ! Thanks! I am glad it is being useful :) Unfortunately the LaTeX backend does not support yet fixed columns. It is a very simple thing to implement, I just need to think about a good API. |
Thanks! I'll be happy to test and give feedback. |
Hi @ronisbr ,
I am just wondering if it is possible to setting maximum column width (
max_colwidth
) with the current version? If not, I think it would be great to have one. Whilescreen_size
option takes the maximum character of the printed table itself, this option can set the maximum character in a column. This is similar on whatpandas.options
has by setting indisplay.max_colwidth
.Another relevant feature, which maybe useful, is user can specify the behavior when the column exceeds
max_colwidth
. With this, the user will be able to choose between crop (...
on remaining characters), or split with new line, that is split the remaining character into new line (maybe split in closest whitespace). The latter is now possible to do with manual work on adding\n
in string withlinebreaks=true
.These options are useful for particularly printing long text data in tabular form.
Thanks
The text was updated successfully, but these errors were encountered: