shenwei356 / csvtk

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

filter2 in csvtk 0.31.1 #295

Open fengyuchengdu opened 3 hours ago

fengyuchengdu commented 3 hours ago

It seems that this update of filter2 broke something during interpreting the logic expression "&&", whereas csvtk 0.31.0 worked well on the same dataset.

shenwei356 commented 2 hours ago

Thanks for reporting this, can you give some data to reproduce it? In my test, it works well.

$ cat names.csv | csvtk filter2 -f '$id > 1 && $first_name == "Robert"'  | csvtk pretty 
[WARN] row 5: Value 'NA' cannot be used with the comparator '>', it is not a number
id   first_name   last_name   username
--   ----------   ---------   --------
4    Robert       Griesemer   gri 
fengyuchengdu commented 2 hours ago

I did some test and seems that the order of column matters in 0.31.1 now. Swapping columns id and first_name to see if it still works.

fengyuchengdu commented 2 hours ago

csvtk filter2 -f '$B == 0 && $A >= 20' example.csv strain B A
GCA_000149305.1 0 77.7364887

csvtk filter2 -f '$A >= 20 && $B == 0' example.csv strain B A

shenwei356 commented 2 hours ago

I see, it's a bug, I'll fix it soon.

fengyuchengdu commented 1 hour ago

That's great. Thank you!

shenwei356 commented 1 hour ago

fixed.