一个可以分析格式化文本的工具

记录一个python工具:可以分析格式化文本

[url]https://raw.githubusercontent.com/harelba/q/master/bin/q[/url]

case:
[url]http://harelba.github.io/q/examples.html[/url]

安装和使用:


curl https://raw.githubusercontent.com/harelba/q/master/bin/q>q
chmod +x q
./q

输出:
q version 1.6.0notreleasedyet
Copyright (C) 2012-2014 Harel Ben-Attia (harelba@gmail.com, @harelba on twitter)
http://harelba.github.io/q/

Must provide at least one query in the command line, or through a file with the -q parameter

例子:

python q 'select * from data.txt'


通过-d 可以指定分隔符

./q -d"," "select c1,c2 from a.txt where c2>2"


通过- 接受命令行

cal|grep -v "2016"|./q -H "select * from - where Sa != ''"



其他:

q "SELECT myfiles.c8,emails.c2 FROM exampledatafile myfiles JOIN group-emails-example emails ON (myfiles.c4 = emails.c1) WHERE myfiles.c8 = 'ppp'"

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

sudo find /tmp -ls | q "SELECT c5,c6,sum(c7)/1024.0/1024 AS total FROM - GROUP BY c5,c6 ORDER BY total desc"

q -t -H "SELECT strftime('%H:%M',date_time) hour_and_minute,count(*) FROM ./clicks.csv GROUP BY hour_and_minute"

q -t -H "SELECT hashed_source_machine,count(*) FROM ./clicks.csv GROUP BY hashed_source_machine"


q -H -t "SELECT request_id,score FROM ./clicks.csv WHERE score > 0.7 ORDER BY score DESC LIMIT 5"


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值