q – Run SQL directly on CSV or TSV files

q is a command line tool that allows direct execution of SQL-like queries on CSVs/TSVs (and any other tabular text files).

q treats ordinary files as database tables, and supports all SQL constructs, such as WHEREGROUP BYJOINs, etc. It supports automatic column name and type detection, and q provides full support for multiple character encodings.

q’s web site is http://harelba.github.io/q/. It contains everything you need to download and use q immediately.

Installation

http://harelba.github.io/q/#installation

Examples

q "SELECT COUNT(*) FROM ./clicks_file.csv WHERE c3 > 32.3"

ps -ef | q -H "SELECT UID, COUNT(*) cnt FROM - GROUP BY UID ORDER BY cnt DESC LIMIT 3"