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

[BUG]Wrong filter2 behaiver when header line contain ”.“ #186

Closed Whale-fall closed 2 years ago

Whale-fall commented 2 years ago

CSVTK version v0.23.0 raw file like this: head vdjdb.slim.txt | cut -f 1,2,3,4,5 image

when I try to select rows by "antigen.gene" using filter2 an error appears head vdjdb.slim.txt | cut -f 1,2,3,4,5 \\ | csvtk filter2 -t -f '$species == "HomoSapiens" && $antigen.gene=="Tat"' Unable to parse numeric value '.' to float64

shenwei356 commented 2 years ago

Try this:


Variables formats:
  $1 or ${1}                        The first field/column
  $a or ${a}                        Column "a"
  ${a,b} or ${a b} or ${a (b)}      Column name with special charactors, 
                                    e.g., commas, spaces, and parentheses

simple tests:

$  echo -ne "a\n1\n2\n" | ./csvtk  filter2 -t -f  '$a > 1'
a
2

$  echo -ne "a\n1\n2\n" | ./csvtk  filter2 -t -f  '${a} > 1'
a
2

$  echo -ne "a\n1\n2\n" | ./csvtk  filter2 -t -f  '$1 > 1'
a
2

$  echo -ne "a (b)\n1\n2\n" | csvtk  filter2 -t -f  '${1} > 1'
a (b)
2

$ echo -ne "a (b)\n1\n2\n" | csvtk  filter2 -t -f  '${a (b)} ==  1'
a (b)
1

$  echo -ne "a,b\n1\n2\n" | ./csvtk  filter2 -t -f  '${a,b} > 1'
a,b
2
Whale-fall commented 2 years ago

Thanks,It looks like a good idea