1CSVGREP(1)                          csvkit                          CSVGREP(1)
2
3
4

NAME

6       csvgrep - csvgrep Documentation
7

DESCRIPTION

9       Filter  tabular data to only those rows where certain columns contain a
10       given value or match a regular expression:
11
12          usage: csvgrep [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
13                         [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H]
14                         [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-n] [-c COLUMNS]
15                         [-m PATTERN] [-r REGEX] [-f MATCHFILE] [-i]
16                         [FILE]
17
18          Search CSV files. Like the Unix "grep" command, but for tabular data.
19
20          positional arguments:
21            FILE                  The CSV file to operate on. If omitted, will accept
22                                  input on STDIN.
23
24          optional arguments:
25            -h, --help            show this help message and exit
26            -n, --names           Display column names and indices from the input CSV
27                                  and exit.
28            -c COLUMNS, --columns COLUMNS
29                                  A comma separated list of column indices, names or
30                                  ranges to be searched, e.g. "1,id,3-5".
31            -m PATTERN, --match PATTERN
32                                  The string to search for.
33            -r REGEX, --regex REGEX
34                                  If specified, must be followed by a regular expression
35                                  which will be tested against the specified columns.
36            -f MATCHFILE, --file MATCHFILE
37                                  If specified, must be the path to a file. For each
38                                  tested row, if any line in the file (stripped of line
39                                  separators) is an exact match for the cell value, the
40                                  row will pass.
41            -i, --invert-match    If specified, select non-matching instead of matching
42                                  rows.
43            -a  --any-match       If specified, select rows where any column matches
44                                  instead of all columns.
45
46       See also: ../common_arguments.
47
48       NOTE: Even though ‘-m’, ‘-r’, and ‘-f’ are listed as  “optional”  argu‐
49       ments, you must specify one of them.
50

EXAMPLES

52       Search for the row relating to Illinois:
53
54          csvgrep -c 1 -m ILLINOIS examples/realdata/FY09_EDU_Recipients_by_State.csv
55
56       Search for rows relating to states with names beginning with the letter
57       “I”:
58
59          csvgrep -c 1 -r "^I" examples/realdata/FY09_EDU_Recipients_by_State.csv
60
61       Search for rows that do not contain an empty state cell:
62
63          csvgrep -c 1 -r "^$" -i examples/realdata/FY09_EDU_Recipients_by_State.csv
64
65       Perform a case-insensitive search:
66
67          csvgrep -c 1 -r "(?i)illinois" examples/realdata/FY09_EDU_Recipients_by_State.csv
68

AUTHOR

70       Christopher Groskopf
71
73       2021, Christopher Groskopf
74
75
76
77
781.0.4                            Jul 23, 2021                       CSVGREP(1)
Impressum