thombashi / pytablewriter

pytablewriter is a Python library to write a table in various formats: AsciiDoc / CSV / Elasticsearch / HTML / JavaScript / JSON / LaTeX / LDJSON / LTSV / Markdown / MediaWiki / NumPy / Excel / Pandas / Python / reStructuredText / SQLite / TOML / TSV.
https://pytablewriter.rtfd.io/
MIT License
610 stars 43 forks source link

Default thousand separator #55

Closed riklopfer closed 2 years ago

riklopfer commented 2 years ago

The default style thousands separator is not behaving as expected.

from pytablewriter import MarkdownTableWriter
from pytablewriter.style import Style

def main():
    table = MarkdownTableWriter(
        headers=("A", "B", "C"),
        value_matrix=[
            (
                "{:,.2%}".format(4000 / 3),
                100000,
                "{:,}".format(100000)
            )
        ],
        default_style=Style(thousand_separator=","),
        margin=1
    ).dumps(flavor="github")

    print(table)

if __name__ == '__main__':
    main()

Actual

|      A      |   B    |   C    |
| ----------- | -----: | -----: |
| 133,333.33% | 100000 | 100000 |

Expected

|      A      |   B     |   C     |
| ----------- | ------: | ------: |
| 133,333.33% | 100,000 | 100,000 |
thombashi commented 2 years ago

@riklopfer Thank you for your report.

I believe the problem fixed at pytablewriter 0.64.2. Please try to upgrade the package and re-execute the program.

riklopfer commented 2 years ago

@thombashi confirmed to be fixed! thanks :)