shenwei356 / csvtk

A cross-platform, efficient and practical CSV/TSV toolkit in Golang
http://bioinf.shenwei.me/csvtk
MIT License
992 stars 84 forks source link

csvtk pretty does not support column range syntax #244

Closed MostafaYA closed 11 months ago

MostafaYA commented 1 year ago

Prerequisites

Describe your issue

Hi, csvtk pretty seems not to support the column range syntax

This works!

$ echo -e "oneoneone,twotwotwo\na1,a2\n,b2\na2,"     | csvtk pretty -W 50  -m 1,2,3
oneoneone   twotwotwo
---------   ---------
   a1          a2    
               b2    
   a2       

This doesnot work

$ echo -e "oneoneone,twotwotwo\na1,a2\n,b2\na2,"     | csvtk pretty -W 50  -m 1-
oneoneone   twotwotwo
---------   ---------
a1          a2       
            b2       
a2                   

Thank you

I'm grateful to users who have greatly helped to report bugs and suggested new features.

I may respond to issues or fix bugs quickly, but I usually implement new features periodically (two or more weeks).

shenwei356 commented 1 year ago

Oh, yes. It's not supported. Since there are two options, -m and -r, it's hard to implement with the current API.

shenwei356 commented 11 months ago

Implemented.

     1b. Texts are aligned left (default), center (-m/--align-center)
         or right (-r/--align-right). Users can specify columns with column names,
         field indexes or ranges.
        Examples:
          -m A,B       # column A and B
          -m 1,2       # 1st and 2nd column          
          -m -1        # the last column (it's not unselecting in other commands)
          -m 1,3-5     # 1st, from 3rd to 5th column
          -m 1-        # 1st and later columns (all columns)
          -m -3-       # the last 3 columns
          -m -3--2     # the 2nd and 3rd to last columns
          -m 1- -r -1  # all columns are center-aligned, except the last column
                       # which is right-aligned. -r overides -m.