1

I am trying to print out emojis as a table using tabulate however I am not getting the right allighment. How can I fix that?

emojis = [['', '', '', '', '', '', ''], 
          ['', '', '', '', '', '', ''], 
          ['' , '', '', '', '', '', ''], 
          ['', '', '', '', '', '', ''], 
          ['', '', '', '', '', '', ''], 
          ['', '', '', '', '', '', ''], 
          ['', '', '', '', '', '', '']]
print(tabulate(emojis, tablefmt="fancy_grid"))

this is what I am getting:

╒═══╤═══╤═══╤═══╤═══╤═══╤═══╕
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
├───┼───┼───┼───┼───┼───┼───┤
│  │  │  │  │  │  │  │
╘═══╧═══╧═══╧═══╧═══╧═══╧═══╛
Hazem Alabiad
  • 1,032
  • 1
  • 11
  • 24
  • What terminal are you using, on what OS? I tried your exact example on ubuntu 20.04 and default terminal `xterm-265color` and works fine. Interestingly enough, in [the documentation](https://pypi.org/project/tabulate/), the part about *tablefmt="fancy_grid"* is shown correct on Chrome on ubuntu, but shows the same error as your when opened on Chrome on Windows. So the operating system is something to think about. – K.Mat Jan 08 '21 at 14:53
  • Working on `Windows` `Bash` terminal. – Hazem Alabiad Jan 08 '21 at 14:59
  • Ubuntu has environmental variable `LANG` set to `"en_GB.UTF-8"`, while Windows has it set to `C` or unset. Try [setting this variable](https://support.shotgunsoftware.com/hc/en-us/articles/114094235653-Setting-global-environment-variables-on-Windows) `LANG` to value `en_GB.UTF-8` and then run your program. If it didn't work, consider reinstalling `tabulate` package after setting the `LANG` var and running program again. – K.Mat Jan 08 '21 at 21:07

0 Answers0