tablewriter icon indicating copy to clipboard operation
tablewriter copied to clipboard

feature request: custom column alignments

Open knz opened this issue 9 years ago • 2 comments

Currently anything that starts with a number is padded left and thus right-aligned. This causes irregular output when a column containing strings happens to contain a string starting with decimal digits.

It would be good to be able to specify alignment for the entire column, for when the alignment type is known beforehand.

Needed to solve https://github.com/cockroachdb/cockroach/issues/10042.

knz avatar Oct 19 '16 17:10 knz

This can easily be fixed. My plan is to use regex to check but would this not be too slow ? Do you have a better solution ?

olekukonko avatar Dec 12 '16 18:12 olekukonko

Yes do not use regexps as this indeed would be too slow. What about a new API next to SetHeader called SetColumnAlignment, taking an array of alignment characters, one per column. Then reuse the specified alignment, and only try to autodetect if no alignment was specified.

knz avatar Dec 20 '16 22:12 knz