-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Option to truncate column headers #165
Comments
Please could you give some example input that causes this? And show the current output and what sort of thing you're after. |
#!/usr/bin/python3
from prettytable import PrettyTable
t = PrettyTable()
t.field_names = ['A Field Name', 'B Field Name', 'D Field Name', 'E Field Name', 'F Field Name', 'G Field Name', 'H Field Name', 'I Field Name', 'J Field Name', 'K Field Name', 'L Field Name', 'M Field Name']
# t.field_names = ['A', 'B', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M']
t.add_row([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
print(t)
# Current:
# +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+
# | A Field Name | B Field Name | D Field Name | E Field Name | F Field Name | G Field Name | H Field Name | I Field Name | J Field Name | K Field Name | L Field Name | M Field Name |
# +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+
# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
# +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+
# Desired:
# +---+---+---+---+---+---+---+---+---+---+----+----+
# | A | B | D | E | F | G | H | I | J | K | L | M |
# +---+---+---+---+---+---+---+---+---+---+----+----+
# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
# +---+---+---+---+---+---+---+---+---+---+----+----+ |
@OlafvdSpek do you think it would be appropriate to add the option to truncate headers? Maybe something like |
Yes, but I'm not sure about the hardest part, the naming. |
@hugovk I can handle adding this feature. Do you have any input on what a good option name might be? |
Sometimes column headers are (much) longer than the column data. An option to ignore the width of the header itself would be nice to have.
The text was updated successfully, but these errors were encountered: