wireservice / csvkit

A suite of utilities for converting to and working with CSV, the king of tabular file formats.
https://csvkit.readthedocs.io
MIT License
6.03k stars 603 forks source link

csvgrep -m "multiple" #1136

Closed tb582 closed 3 years ago

tb582 commented 3 years ago

Looking at the docs for csvgrep https://csvkit.readthedocs.io/en/1.0.2/scripts/csvgrep.html

I don't inherently see a way to search for multiple strings? Am I missing something?

csvgrep -c 1 -m "test" -m " test2" file.csv | csvlook | less -s

tb582 commented 3 years ago

Kinda figured out a hack solution using regex:

(?:^|W)thing1|thing2|something else(?:$|\W)

jpmckinney commented 3 years ago

Yes, the way to search multiple strings is to use a regex. Typically one|two|three and if you want to match word boundaries \b(one|two|three)\b, or if you want to match only exact strings then ^(one|two|three)$.