Asis Patra

@asispatra

Bengaluru, India

Print csv in tabular form: csv2table

by on September 18, 2022 at 6:48 pm

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

Category: Linux

Tags: , ,

 

Let’s try to write a sample assembly language code and then compile and run it on Linux x86 platform. This code will just print Hello World. There are several way to write the assembly code. You can find more details here. I have picked one of them. Programming Using System Calls 64-bit Linux installations use […]  Read More »

Category: Linux

Build column Command on Linux

by on September 18, 2022 at 7:15 pm

You might have bsd version column on your system, which might be an older version. You can build column using the following steps. Build column  Read More »

Category: Linux