Issue #30 wontfix

Int Formatting Like Float Formatting

Anonymous created an issue

In order to print integer output with comma separators, I think you should be able to pass in an integer formatting string the same way you can pass in a float format string. It shouldn't require a big change. Something like:

    if valtype is int:
        return format(int(val), intfmt)
    elif valtype is _text_type:
        return "{0}".format(val)

and then making sure to pass the intfmt string from tabulate to _format

Comments (1)

  1. Sergey Astanin repo owner

    I think this feature does not belong to tabulate.

    • An easy workaround is to convert int values to float before calling tabulate
    • Using int values where float values are supposed to be used often leads to buggy Python code. For example, `int(5)/int(4)' is not the same thing in Python2 and in Python3.
    • Per-column data type specification and alignment will probably be available in furute versions (something along the lines of colaligns=..., coltypes=...)
  2. Log in to comment