wilsonfreitas / csvgrep

Easy and funny searches on text delimited files
http://wilsonfreitas.github.io/csvgrep
MIT License
5 stars 1 forks source link

Allow multiple boolean expressions in one rule #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A comma delimited list of boolean expressions defined inside one rule would 
allow more flexibility for creating
filters.

csvgrep '@all $NR == 5, $1 eq "^$", $7 > 0 ; ${name}' file.csv

prints $NR, $1, $7, ${name} when the first statement values true and it is
evaluated to true if all boolean expressions value true

Note the @all statement function, other approach is @any that evaluates to
true if at least one boolean expression values true. 
These are AND and OR clauses.
We also could have @none expression function or either @not operating on those 
expressions.

Every time someone works with that expression one of the above expression 
functions must be called (@all, @any or @none).
There is no standard behavior.

What about hiding fields?
All columns referred in a multiple expression are sent to output? 
So, if someone wants to hide some column, what should be done?

Suggestion:

If @hide is called all references are hidden.
A reference can be hidden into one statement and called into another

csvgrep '@hide @all $NR == 5, $1 eq "^$", $7 > 0 ; ${name} ; $7' file.csv

Original issue reported on code.google.com by wilson.freitas on 9 Jul 2012 at 11:42