Here is a fascinating command-line tool that will surely pique your curiosity and be of great service to you. This is Trdsql, a program written in Go that allows you to execute SQL queries on structured text files such as CSV, TSV, LTSV, TBLN, and JSON.
At this level, it’s like witchcraft, sir!!
Trdsql has been around for a while and is known for its performance and capabilities. For example, it can execute real SQL queries from .sql files (whether MySQL or PostgreSQL queries).
It is an advanced alternative to q and textql, which also provide the ability to run SQL queries on structured CSV and TSV files. However, Trdsql outperforms its predecessors by supporting more file formats, offering different output options, and processing compressed files.
In addition to all the file formats it manages, it offers various output formats such as raw output, ASCII tables, Markdown, etc. Another advantage of Trdsql is that it can be used as a library for your Go programs, enabling you to process large files seamlessly within your own processes.
Take, for example, a CSV containing a list of tasks from which you want to extract specific information. With Trdsql, you can use a simple SQL query to retrieve the desired data:
trdsql "SELECT * FROM test.csv"
Trdsql is very user-friendly and is available on Linux, Windows, and macOS. You can also launch it via a Docker container.
Therefore, it is a valuable tool for those working with structured data and “flat” files.
Don’t hesitate to test Trdsql for yourself by clicking here.