shenwei356 / csvtk

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

"csvtk sep -H -N N --drop" output can be incorrect #230

Closed tetedange13 closed 1 year ago

tetedange13 commented 1 year ago

Prerequisites

Describe your issue

csvtk sep --no-header-row --num-cols N --drop does not work correctly when 1 row of column to be separated has (strictly) more fields than --num-cols

INCORRECT :

$ echo -e "gender,name\nmale,A;B;C;D\nfemale,a;b;c;d" | csvtk del-header | csvtk sep -f 2 -s ';' --num-cols 3 --no-header-row --drop | csvtk pretty -H male A;B;C;D A B C D female a;b;c;d a b c d

<br>

Output is correct if 1st row has a number of fields to separate equal (or less) than `--num-cols` :

CORRECT :

$ echo -e "gender,name\nmale,A;B;C\nfemale,a;b;c;d" | csvtk del-header | csvtk sep -f 2 -s ';' --num-cols 3 --no-header-row --drop | csvtk pretty -H male A;B;C A B C female a;b;c;d a b c



### 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

Sorry for the late reply. It's a previously reported bug, and it's fixed then. #218

I've just tested your test data, it works as expected.