-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct syntax for filtering multiple values on a single column #1591
Comments
Do you want to filter all records in which column1 is equal to TEST1 or
TEST2?
______
Scusami per la brevità, ti sto scrivendo dal cellulare.
website: https://medium.com/tantotanto
38° 7' 48" N, 13° 21' 9" E EPSG:4326
Il lun 17 giu 2024, 22:43 Karu Donaldson ***@***.***> ha
scritto:
… Wanting to filter multiple values TEST1 and TEST2 on a single column.
My earlier post <#1590> may
answer this one but thought I'd post it separately just in case.
Trying with && but perhaps I'm missing something?
mlr -- filter '$COLUMN1 == "TEST1" && "TEST2"' input.csv > output.csv
—
Reply to this email directly, view it on GitHub
<#1591>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAHPD7IJQYKO7TSGVKLCKTZH5C77AVCNFSM6AAAAABJOWUIUWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2TQMRSGI2TEMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@karudonaldson do you want to include rows for which
|
Awesome, exactly what I was looking for. Then to clarify further, if I'm combining multiple values on a single column with multiple values on other columns, would this be the correct syntax?
|
Yes, but you need to know about operator precedence if you're going to mix Regardless of any particular programming language's precedence rules, when mixing
or
depending on which of those are what you mean ... |
Would you mind breaking down what the key difference is here for clarity. |
@karudonaldson consider the following input:
One way:
This prints no rows. Why? Because AND of things means they all must be true, and, not all of the following are true:
Then parentheses another way:
This prints
Why? Because OR of things mean at least one must be true, and one of the following is true:
So, you need to decide what you want your filter expression to test for. |
That makes total sense! Thanks for taking the time to explain that. Now it's clear :) |
Re-opening since I ran into another snag. input.csv
Expecting:
|
@karudonaldson here's what I have:
|
Ouch I found the problem at my end. The string "TEST.1" has white space after it! I've seen this before in other CSV's and we came to the conclusion it makes sense if we detect the whitespace overwrite the entire cell with the correct string name "TEST.1" then apply the filter. sigh What is your suggestion for handling this scenario? I tried filtering "TEST.1*" but that didn't help. |
Hi, you have a verb to clean this kind of problems: |
Indeed, and/or, filter |
EDIT: With the clean new output.csv I run filter rules against it. :) |
Wanting to filter multiple values TEST1 and TEST2 on a single column.
My earlier post may answer this one but thought I'd post it separately just in case.
Trying with && but perhaps I'm missing something?
mlr -- filter '$COLUMN1 == "TEST1" && "TEST2"' input.csv > output.csv
The text was updated successfully, but these errors were encountered: