2021-11-01 22:32:54 +00:00
|
|
|
# textql
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
> Execute SQL against structured text like CSV or TSV files.
|
2021-11-01 22:32:54 +00:00
|
|
|
> More information: <https://github.com/dinedal/textql>.
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
- Print the lines in the specified CSV file that match an SQL query to `stdout`:
|
2021-11-01 22:32:54 +00:00
|
|
|
|
|
|
|
`textql -sql "{{SELECT * FROM filename}}" {{path/to/filename.csv}}`
|
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
- Query a TSV file:
|
2021-11-01 22:32:54 +00:00
|
|
|
|
|
|
|
`textql -dlm=tab -sql "{{SELECT * FROM filename}}" {{path/to/filename.tsv}}`
|
|
|
|
|
|
|
|
- Query file with header row:
|
|
|
|
|
|
|
|
`textql -dlm={{delimiter}} -header -sql "{{SELECT * FROM filename}}" {{path/to/filename.csv}}`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Read data from `stdin`:
|
2021-11-01 22:32:54 +00:00
|
|
|
|
|
|
|
`cat {{path/to/file}} | textql -sql "{{SELECT * FROM stdin}}"`
|
|
|
|
|
|
|
|
- Join two files on a specified common column:
|
|
|
|
|
2024-01-31 03:55:19 +00:00
|
|
|
`textql -header -sql "SELECT * FROM {{path/to/file1}} JOIN {{file2}} ON {{path/to/file1}}.{{c1}} = {{file2}}.{{c1}} LIMIT {{10}}" -output-header {{path/to/file1.csv}} {{path/to/file2.csv}}`
|
2021-11-01 22:32:54 +00:00
|
|
|
|
|
|
|
- Format output using an output delimiter with an output header line:
|
|
|
|
|
|
|
|
`textql -output-dlm={{delimiter}} -output-header -sql "SELECT {{column}} AS {{alias}} FROM {{filename}}" {{path/to/filename.csv}}`
|