2016-01-21 18:03:29 -05:00
|
|
|
# csvgrep
|
|
|
|
|
|
|
|
> Filter CSV rows with string and pattern matching.
|
|
|
|
> Included in csvkit.
|
2019-06-09 00:05:31 +01:00
|
|
|
> More information: <https://csvkit.readthedocs.io/en/latest/scripts/csvgrep.html>.
|
2016-01-21 18:03:29 -05:00
|
|
|
|
|
|
|
- Find rows that have a certain string in column 1:
|
|
|
|
|
2025-04-22 15:48:30 +03:00
|
|
|
`csvgrep {{[-c|--columns]}} {{1}} {{[-m|--match]}} {{string_to_match}} {{data.csv}}`
|
2016-01-21 18:03:29 -05:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Find rows in which columns 3 or 4 match a certain regular expression:
|
2016-01-21 18:03:29 -05:00
|
|
|
|
2025-04-22 15:48:30 +03:00
|
|
|
`csvgrep {{[-c|--columns]}} {{3,4}} {{[-r|--regex]}} {{regular_expression}} {{data.csv}}`
|
2016-01-21 18:03:29 -05:00
|
|
|
|
|
|
|
- Find rows in which the "name" column does NOT include the string "John Doe":
|
|
|
|
|
2025-04-22 15:48:30 +03:00
|
|
|
`csvgrep {{[-i|--invert-match]}} {{[-c|--columns]}} {{name}} {{[-m|--match]}} "{{John Doe}}" {{data.csv}}`
|