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

Column headers do not respond to flags set to position new columns in mutate2 cmd #252

Closed MostafaYA closed 11 months ago

MostafaYA commented 11 months ago

Prerequisites

Describe your issue

csvtk version v0.27.2

column headers do not respond to flags --at --after or --before in the mutate2 command

Here is the example from the manual

echo -ne "a,b,c\n1,2,3\n" | csvtk mutate2 -e '$a+$c' -n x -w 0 --at 1
a,b,c,x
4,1,2,3

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 11 months ago

Oh, sorry about that, the code was accidentally missing during code refactoring in v0.27.0.

$ echo -ne "a,b,c\n1,2,3\n" | csvtk mutate2 -e '$a+$c' -n x -w 0 --at 1
x,a,b,c
4,1,2,3

$ echo -ne "a,b,c\n1,2,3\n" | csvtk mutate2 -e '$a+$c' -n x -w 0 --after b
a,b,x,c
1,2,4,3

$ echo -ne "a,b,c\n1,2,3\n" | csvtk mutate2 -e '$a+$c' -n x -w 0 --before b
a,x,b,c
1,4,2,3
MostafaYA commented 11 months ago

Thanks!

tolot27 commented 9 months ago

This problem is still not fixed with external variables which were introduced with #37.

val=ABC; echo -ne "a,b,c\n1,2,3\n" | csvtk mutate2 -e " '$val' " -n x --at 1
a,b,c,x
1,2,3,ABC
shenwei356 commented 9 months ago

Thanks for reporting this. Previously, when the expression only contained constant strings or numbers, another simple workflow was used, in which I forgot to apply the position to insert.