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 unselect range error #234

Closed tolot27 closed 1 year ago

tolot27 commented 1 year ago

The range selector to "discard 1st to 3rd column" does not work as documented:

echo -e "1,2,3,4,5" | csvtk -H cut -f -1--3
[ERRO] invalid field range: -1--3. start (-1) should be less than end (-3)

It does not matter which numbers are used. It looks like the first dash is treated as the "minus" of the first number rather than as the unselect operater.

Both version 0.25 and 0.26 are affected.

avilella commented 1 year ago

I mentioned this in the past. For me, it works if you change the order of the range to exclude, e.g.:

echo -e "1,2,3,4,5" | csvtk -H cut -f -3--1

Here you exclude 1,2,3, only you are telling it to exclude 3,2,1 instead.

On Wed, Jul 12, 2023 at 1:35 PM Mathias Walter @.***> wrote:

The range selector to "discard 1st to 3rd column" does not work as documented:

echo -e "1,2,3,4,5" | csvtk -H cut -f -1--3 [ERRO] invalid field range: -1--3. start (-1) should be less than end (-3)

It does not matter which numbers are used. It looks like the first dash is treated as the "minus" of the first number rather than as the unselect operater.

Both version 0.25 and 0.26 are affected.

— Reply to this email directly, view it on GitHub https://github.com/shenwei356/csvtk/issues/234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGSN3ME5TB7OM7GQQZUVLXP2KZXANCNFSM6AAAAAA2HNQXTQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

shenwei356 commented 1 year ago

Oh, both ways are supported now.

$ echo -e "1,2,3,4,5" | csvtk -H cut -f -1--3
4,5
$ echo -e "1,2,3,4,5" | csvtk -H cut -f -3--1
4,5