align-center and align-right for specific columns
tolot27 opened this issue · 2 comments
tolot27 commented
I'm using csvtk v0.26 and it would be great if pretty
can be extended to align specific columns only, i. e. by specifying column numbers with -m, --align-center
and -r, --align-right
.
Example of current output:
echo -e "contigs,sum_bases,cov,species\n37,31322,10.8,Homo sapiens\n1,11028,2388.5,Orthoflavivirus" | csvtk pretty -S plain
contigs sum_bases cov species
37 31322 10.8 Homo sapiens
1 11028 2388.5 Orthoflavivirus
or
echo -e "contigs,sum_bases,cov,species\n37,31322,10.8,Homo sapiens\n1,11028,2388.5,Orthoflavivirus" | csvtk pretty -S plain -r
contigs sum_bases cov species
37 31322 10.8 Homo sapiens
1 11028 2388.5 Orthoflavivirus
desired output:
echo -e "contigs,sum_bases,cov,species\n37,31322,10.8,Homo sapiens\n1,11028,2388.5,Orthoflavivirus" | csvtk pretty -S plain -m 1 -r 2,3
contigs sum_bases cov species
37 31322 10.8 Homo sapiens
1 11028 2388.5 Orthoflavivirus
shenwei356 commented
That's useful.
shenwei356 commented
Supported.
Use binaries here: #91 (comment)
$ echo -e "contigs,sum_bases,cov,species\n37,31322,10.8,Homo sapiens\n1,11028,2388.5,Orthoflavivirus" \
| csvtk pretty -S plain -m 1 -r 2,3
contigs sum_bases cov species
37 31322 10.8 Homo sapiens
1 11028 2388.5 Orthoflavivirus
$ echo -e "contigs,sum_bases,cov,species\n37,31322,10.8,Homo sapiens\n1,11028,2388.5,Orthoflavivirus" \
| csvtk pretty -S plain -m contigs -r sum_bases,cov
contigs sum_bases cov species
37 31322 10.8 Homo sapiens
1 11028 2388.5 Orthoflavivirus
$ csvtk pretty testdata/names.csv -r 1,username -m first_name
┏━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━┓
┃ id ┃ first_name ┃ last_name ┃ username ┃
┣━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━┫
┃ 11 ┃ Rob ┃ Pike ┃ rob ┃
┣━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━┫
┃ 2 ┃ Ken ┃ Thompson ┃ ken ┃
┣━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━┫
┃ 4 ┃ Robert ┃ Griesemer ┃ gri ┃
┣━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━┫
┃ 1 ┃ Robert ┃ Thompson ┃ abc ┃
┣━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━┫
┃ NA ┃ Robert ┃ Abel ┃ 123 ┃
┗━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━┛