Skip to main content

Query a CSV using SQL

Query a CSV using SQL. Wrk Action uses SQLite syntax.

SQLLite Documentation: https://www.sqlite.org/docs.html

Application

  • CSV

Inputs (what you have)

NameDescriptionData TypeRequired?Example
CSV fileCSV file you would like to query using SQLFileYes
SQL queryA SQL query to perform on the provided CSV. Your primary table will always be referenced as CSV. Example: Select * from CSVText (Long)YesSelect * from CSV
Columns do not have headers?If selected, the headers will be referred to as Col1, Col2, etcTrue/FalseNo
SeparatorThe character used to separate columns in the CSV. Will default to ,Text (Short)No,
Quote characterThe characters used to indicate a string in the CSV. Will default to “Text (Short)No“
Preserve null-like textKeep literal text such as NA, NULL, null, NaN and N/A instead of SQL NULL. Defaults to false. Empty cells still become SQL NULL.True/FalseNofalse
Output filenameOptional custom filename for the output CSV fileText(Long)Nosample.csv

Leading zeros and column types

Columns containing integers with leading zeros, such as 00123 or 00007, are automatically treated as text. The entire column keeps its text values, so 00123 and 123 remain distinct in queries and in the CSV and JSON results. Other columns continue to use automatic type detection. A single zero (0) or an ordinary decimal (0.50) does not cause a column to be treated as text.

Use quoted text values when filtering these columns, for example WHERE account_id = '00123'. To compare or sort them numerically, use CAST(account_id AS INTEGER). Configure captured identifier outputs as Text to preserve their leading zeros.

Empty cells and null-like text

By default, empty cells and recognized null-like text, including NA, NULL, null, NaN and N/A, become SQL NULL. Quoting these values does not preserve them under the default setting.

Enable Preserve null-like text to keep these literal strings. For example, WHERE value = 'NA' then matches both NA and "NA" in the source CSV. Empty cells, including quoted empty cells (""), still become SQL NULL; use WHERE value IS NULL to find them. CSV has no separate native null type, and SQL-generated NULL values remain null.

The setting defaults to false, so existing Wrkflows retain their null handling. It only changes null-token recognition: other column type detection and the parsing of JSON objects and arrays in JSON outputs still apply. In the output CSV, SQL NULL is written as an empty cell.

Outputs (what you get)

NameDescriptionData TypeRequired?Example
Output CSVOutput CSV fileFileYes

Outcomes

NameDescription
SuccessThis status is selected if the job has successfully completed.

Examples:

  • Examples to come