There is a command named column
which already helps you to print csv in tabular form. Here, we have used the same column
command in csv2table
script which automatically take care of the header and prints in tabular form with border.
Example
$ column -V
column from util-linux 2.32.1
$ cat csv.data
Instance,JTHREADS,JDURATION,Throughputs,Avg. Resp. Time,Min. Resp. Time,Max. Resp. Time,Error
1,20,1800,1984.6,9,0,131,0 (0.00%)
2,20,1800,1933.6,9,0,125,0 (0.00%)
3,20,1800,1976.7,9,0,159,0 (0.00%)
4,20,1800,1897.2,10,0,130,0 (0.00%)
$ csv2table csv.data
---------+----------+-----------+-------------+-----------------+-----------------+-----------------+-----------------
Instance | JTHREADS | JDURATION | Throughputs | Avg. Resp. Time | Min. Resp. Time | Max. Resp. Time | Error
---------+----------+-----------+-------------+-----------------+-----------------+-----------------+-----------------
1 | 20 | 1800 | 1984.6 | 9 | 0 | 131 | 0 (0.00%)
2 | 20 | 1800 | 1933.6 | 9 | 0 | 125 | 0 (0.00%)
3 | 20 | 1800 | 1976.7 | 9 | 0 | 159 | 0 (0.00%)
4 | 20 | 1800 | 1897.2 | 10 | 0 | 130 | 0 (0.00%)
---------+----------+-----------+-------------+-----------------+-----------------+-----------------+-----------------
Note: Please make sure you are using latest column
version. You can build column
on linux. Steps can be found here.
Download Script
curl "https://asispatra.github.io/vault/csv2table" -o "csv2table"
sudo mv csv2table /usr/local/bin/
sudo chmod a+rx /usr/local/bin/csv2table