33

Run SQL directly on CSV files with q

 5 years ago
source link: https://www.tuicool.com/articles/hit/jAFVjqu
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

New windows version 1.7.4 has been released which fixes a bug that writes a warning to stdout. Other releases remain in version 1.7.1

Version1.7.1 is out. Main feature is allowing to write the data to a disk-based sqlite3 database file. Any feedback is most welcome

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 WHERE, GROUP BY, JOINs etc. It supports automatic column name and column type detection, and provides full support for multiple encodings.

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"

Look at theexamples page for some more examples, or just download the tool using the links above or in theinstallation page and play with it.

完全支持所有的字符编码

すべての文字エンコーディングを完全にサポート

모든 문자 인코딩이 완벽하게 지원됩니다

все кодировки символов полностью поддерживаются

Non-english users:q fully supports all types of encoding. Use "-e data-encoding" to set the input data encoding, "-Q query-encoding" to set the query encoding, and use "-E output-encoding" to set the output encoding. Sensible defaults are in place for all three parameters. Please contact me if you encounter any issues and I'd be glad to help.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK