csvfix eval -if woes

64 views
Skip to first unread message

Aaron Lowndes

unread,
Jun 10, 2016, 12:31:52 PM6/10/16
to csvfix
Trying to do something pretty simple, in english
If the value in column 9 is "DR" then multiply the value in column 10 by -1. i.e. make it negative.

Have tried:

csvfix eval -if '$9=="DR"' -r 10,'-($10)' -r 10,'($10)' b.csv
but that doesn't do the appropriate calculation on the value in column 10 for my test row;


tried replacing "r" with "e" as in the help file:
csvfix eval -if '$9=="DR"' -e 10,'-($10)' -e 10,'($10)' b.csv
ERROR
: Invalid expression



tried getting rid of csvfix's eval if and using an eval (if formula) instead:
csvfix eval -r 10,"if($9="DR",$10*(-1),$10)" b.csv

ERROR: Compilation error - Invalid operator  in if(=DR,t0*(-1),t0)


maybe it needed two == signs after all:
csvfix eval -r 10,"if($9=="DR",$10*(-1),$10)" b.csv
ERROR
: Invalid expression


I'm pretty stuck with this, so any help is much appreciated :) Thanks for a wonderful tool!

Aaron





Neil Butterworth

unread,
Jun 10, 2016, 12:38:26 PM6/10/16
to csvfix
You need to get your quoting right - this should work on Windows:

       csvfix eval -r 10,"if($9=='DR',-1*$10,$10)" b.csv

Aaron Lowndes

unread,
Jun 11, 2016, 1:05:16 PM6/11/16
to csvfix
Thanks. I am on OSX, and I eventually got it working by putting the quote marks earlier like this:

csvfix eval -if 'match($9,"DR")' -r '10,-$10' -r '10,$10' b.csv

Cheers,
Reply all
Reply to author
Forward
0 new messages