astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.1k stars 163 forks source link

Cannot handle mixed English and Chinese characters #253

Closed tanjt107 closed 1 year ago

tanjt107 commented 1 year ago

When using the tabulate package in Python to create a table containing both English and Chinese characters, the resulting table may not align properly due to the different character widths. This can cause the columns to be misaligned and make the table difficult to read.

Example:

| Team       |   Matches Played |   Goal Difference |   Points |
|------------|------------------|-------------------|----------|
| EVOSA      |                3 |                36 |        6 |
| 元朗區體育會     |                3 |                21 |        6 |
| 威濤         |                3 |                15 |        5 |
| 南華         |                2 |                57 |        4 |
| HKG GIANTS |                3 |                 5 |        4 |
| 順利天主教      |                3 |                -2 |        3 |
| SCAA       |                3 |                 8 |        2 |
| 科士         |                3 |                -4 |        2 |
| HBM        |                3 |               -12 |        2 |
| 香港教育大學     |                3 |               -24 |        2 |
| 東區         |                2 |                -3 |        0 |
| MAGIC      |                3 |               -41 |        0 |
| 元朗區青年隊     |                2 |               -56 |        0 |
svisser commented 1 year ago

Are you using the wcwidth library? See: https://github.com/astanin/python-tabulate#wide-fullwidth-cjk-symbols

tanjt107 commented 1 year ago

Thanks. I am closing this issue.