A handy command to re-format tables separated by common elements: column

man column

DESCRIPTION
     The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by default, from the standard input. Empty lines are ignored.


Say there is a table separated by commas as following:

object,categoryA,categoryB,categoryC,categoryD,categoryE,categoryF
nameA,3553,1200,100,0,150,240
nameB,1000,500,736,0,0,0
nameC,4882,500,0,400,0,0
nameD,500,350,0,0,0,1000
nameE,250,0,500,0,175,0
nameF,60,250,0,0,786,560
nameG,0,0,1000,0,3000,0
nameH,491,200,0,120,277,0

In vim, this can be then converted using the column utility:

:%!column -t -s ','

And the table changes to:

object  categoryA  categoryB  categoryC  categoryD  categoryE  categoryF
nameA   3553       1200       100        0          150        240
nameB   1000       500        736        0          0          0
nameC   4882       500        0          400        0          0
nameD   500        350        0          0          0          1000
nameE   250        0          500        0          175        0
nameF   60         250        0          0          786        560
nameG   0          0          1000       0          3000       0
nameH   491        200        0          120        277        0