Skip to content

csvgrep: add --ignore-case option for case-insensitive matching - #1356

Open
ChrisJr404 wants to merge 1 commit into
wireservice:masterfrom
ChrisJr404:csvgrep-ignore-case
Open

csvgrep: add --ignore-case option for case-insensitive matching#1356
ChrisJr404 wants to merge 1 commit into
wireservice:masterfrom
ChrisJr404:csvgrep-ignore-case

Conversation

@ChrisJr404

Copy link
Copy Markdown

Fixes #1273.

csvgrep currently has no case-insensitivity toggle. As noted in the issue (and #248 before it), the only way to match case-insensitively today is to embed an inline (?i) flag inside a -r regular expression, which doesn't help the -m (string) or -f (matchfile) options at all.

This adds an --ignore-case flag that applies to all three matchers:

  • -m / --match — substring compared case-insensitively
  • -r / --regex — pattern compiled with re.IGNORECASE
  • -f / --file — matchfile lines and cell values compared lowercased

The short -i is already taken by --invert-match, so the option is long-form only, matching grep's --ignore-case spelling.

Default behaviour is unchanged: matching stays case-sensitive unless --ignore-case is passed.

$ csvgrep -c 1 --ignore-case -m illinois examples/realdata/FY09_EDU_Recipients_by_State.csv
State Name,State Abbreviate,...
ILLINOIS,IL,17,...

Includes tests for -m, -r and -f (plus a check that the default stays case-sensitive), and updates the csvgrep docs, CHANGELOG and AUTHORS.

Adds an --ignore-case flag to csvgrep that matches case-insensitively for
the -m (string), -r (regex) and -f (matchfile) options. Previously a
case-insensitive match was only possible by embedding an inline (?i) flag
in a regular expression. Default behaviour is unchanged (case-sensitive).

Closes wireservice#1273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csvgrep: Add case-insensitive option (instead of using flag in regex string)

1 participant