Guides/

How to Filter a CSV File With SQL

You do not need a database to query a CSV. In CSVUtility, Edit → Filter… (or Command Palette… then “Filter…”) opens a filter bar on the same workspace row as Find & Replace.

You type a condition. You do not type SELECT * FROM.

Open the WHERE bar

  1. Open the CSV in CSVUtility.
  2. Choose Edit → Filter…, click Filter on the tool strip, or press ⌘⇧P and run Filter….
  3. The field placeholder is Enter a SQL WHERE clause. Syntax is coloured as you type: keywords, columns, strings, numbers.
  4. Press Return or click Apply Filter. Clear Filter lifts it. Escape or the close control hides the bar.

If the clause does not compile, Apply Filter stays disabled and a red band shows the parser error, including line and column. Unknown headers are coloured as mistakes before you apply.

⌘Z in the field undoes typing in the clause first, then undoes applying the filter.

What the dialect actually supports

From the app’s WHERE compiler:

  • Header names, or Excel-style letters A, B, AA (a real header always wins over the letter)
  • Quoted names: "First Name", [First Name], or backtick-wrapped names
  • =, !=, <>, <, <=, >, >=
  • AND, OR, NOT, and parentheses
  • IS NULL, IS NOT NULL, LIKE, NOT LIKE
  • String, numeric, boolean, and null literals

Comparisons with < / > try numeric order when both sides look like numbers. = on two strings is case-sensitive by default.

Empty cells are NULL. A blank CSV field is treated as SQL NULL, so Notes IS NULL matches blanks. Notes = '' is not the default way to find empties.

Booleans in cells can be true / false, yes / no, or 1 / 0.

LIKE

% matches any run of characters. _ matches one character. \ escapes the next character.

Code LIKE 'A_%'
Code LIKE 'A\_%'
Code NOT LIKE '%test%'

The first matches A-100. The second matches a literal underscore after A.

Examples that compile

status = 'Paid'
region = 'West' AND net_revenue > 1000
"First Name" LIKE 'Ad%' OR [First Name] = 'Grace'
NOT (status = 'Refunded' OR status = 'Cancelled')
Active = FALSE

Header names in the first row are the column names. If a name is wrong, the error is Unknown column '…'. Use a header name or column letter.

Filters change what else you can do

While a filter is active, CSVUtility keeps the header row and hides non-matching data rows. Sort… is blocked (you will hear the system beep). Structural column operations are blocked, because reordering a filtered view would be ambiguous.

To save only what you see: File → Export Copy… (⌘E) and set Rows to Current filtered view.

Value filters on a column

The header caret (visible on hover) opens an Excel-style value filter: checkboxes, Search, Select All, blanks shown as (Blanks), plus sort shortcuts. Distinct values in that popover cap at the first 10,000 unique values.

Use the caret when a column has a short list of statuses. Use the WHERE bar when you need AND, OR, LIKE, or numeric comparisons.

Large files

Filtering keeps the grid usable while it runs. In the 1 GB test, a two-condition filter over 12.49 million rows took 14.58 seconds (middle of three runs). See the benchmarks for the rest of that run. For files that would lock a browser tab, download CSVUtility.

Need this on a large file?

CSVUtility opens huge CSVs on a Mac. Search, filter, and compare changes without waiting on a spinner.

Download for MacOS