Board logo

标题: [文本处理] dsq:用于针对JSON,CSV,Excel,Parquet等运行SQL查询的命令行工具 [打印本页]

作者: CrLf    时间: 2023-7-29 00:59     标题: dsq:用于针对JSON,CSV,Excel,Parquet等运行SQL查询的命令行工具

本帖最后由 CrLf 于 2023-7-29 01:04 编辑

来源:GitHub - multiprocessio/dsq:用于针对JSON,CSV,Excel,Parquet等运行SQL查询的命令行工具。

计算数量
  1. type testdata.parquet | dsq -s parquet "SELECT COUNT(1) FROM {}"
  2. +----------+
  3. | count(*) |
  4. +----------+
  5. |     1000 |
  6. +----------+
复制代码
展示第一行
  1. cat testdata.csv | dsq -s csv "SELECT * FROM {} LIMIT 1"
复制代码
连接多表
  1. dsq testdata/join/users.csv testdata/join/ages.json "select {0}.name, {1}.age from {0} join {1} on {0}.id = {1}.id"
  2. [{"age":88,"name":"Ted"},
  3. {"age":56,"name":"Marjory"},
  4. {"age":33,"name":"Micah"}]
复制代码
排序
  1. dsq --pretty api-results.json 'SELECT * FROM {0, "data.data"} ORDER BY id DESC'
  2. +----+-------+
  3. | id | name  |
  4. +----+-------+
  5. |  3 | Minh  |
  6. |  1 | Corah |
  7. +----+-------+
复制代码
已收录到 http://bcn.bathome.net/s/tool/index.html?key=dsq




欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2