LinuxCommandLibrary

textql

Execute SQL queries on CSV files

TLDR

Query CSV

$ textql -sql "[SELECT * FROM file]" [data.csv]
copy
With header
$ textql -header -sql "[SELECT name FROM file]" [data.csv]
copy
Custom delimiter
$ textql -dlm=";" -sql "[query]" [data.csv]
copy
Save to SQLite
$ textql -save-to [output.db] [data.csv]
copy
Output to file
$ textql -output-file [result.csv] -sql "[query]" [data.csv]
copy

SYNOPSIS

textql [-sql query] [-header] [-dlm delim] [options] files

DESCRIPTION

textql allows running SQL queries against structured text files such as CSV and TSV. It loads files into an in-memory SQLite database, treating each file as a table, and executes standard SQL queries against them.
When -header is specified, the first row is used for column names; otherwise columns are named c0, c1, etc. Multiple files can be loaded simultaneously and joined using SQL JOIN syntax. The -save-to option persists the imported data to a SQLite database file for further analysis. Custom delimiters are supported with the -dlm flag.

PARAMETERS

-sql QUERY

SQL query.
-header
First row is header.
-dlm CHAR
Field delimiter.
-save-to FILE
Save to SQLite.
-output-file FILE
Output file.
-output-dlm CHAR
Output delimiter.

CAVEATS

Memory for large files. SQLite limitations. Go-based tool.

HISTORY

textql was created to execute SQL queries against structured text files like CSV using SQLite.

SEE ALSO

sqlite3(1), csvq(1), q(1), miller(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community