python 统计pvuv 二
来源:互联网 发布:nginx伪静态规则写法 编辑:程序博客网 时间:2024/06/06 15:54
test.py
#!/usr/bin/pythonimport osimport sysimport stringimport json#awk -F ',' 'substr($0,21,2)=='14'{print $0}' * > 14.logdef run():logfile = '14.log'res = dict()if not os.path.exists(logfile): print 'error:' + logfile + ' not existed.' print 'hint:awk -F \',\' \'substr($0,21,2)==\'14\'{print $0}\' WB_LOG_LOAD* > 14.log' exit()#time zonedts = set()dts.add('2015-04-29 00')dts.add('2015-04-29 01')dts.add('2015-04-29 02')dts.add('2015-04-29 03')dts.add('2015-04-29 04')dts.add('2015-04-29 05')dts.add('2015-04-29 06')dts.add('2015-04-29 07')dts.add('2015-04-29 08')f = open(logfile,'r')line = f.readline()while line:if line[0:13] not in dts: #print line[0:13]line = f.readline()continue arr = line.split(',')if len(arr) != 7:line = f.readline()continue #log id and setkey are existed. if arr[2] and arr[5]: #print arr[1][3:] key = arr[5] item = res.get(key, -1) if -1 == item: item = {'pv':0, 'uvSet':set([])} res[key] = item item['pv'] = item['pv'] + 1 item['uvSet'].add(arr[2]) #print len(arr)line = f.readline()f.close()for item in res: print item + ' pv:' + str(res[item]['pv']) + ' uv:' + str(len(res[item]['uvSet']))
main.py
#!/usr/bin/pythonimport osimport sysimport testif '__main__' == __name__:num = 20if len(sys.argv) > 1:num = int(sys.argv[1])#run(num)test.run()
0 0
- python 统计pvuv 二
- python 统计pvuv 一
- pvuv统计设计
- PVUV
- Python学习笔记(二)列表统计词频
- Python学习笔记(二)列表统计词频
- Python与机器学习之Numpy描述性统计(二)
- python 统计
- python实现爬虫统计学校BBS男女比例(二)多线程爬虫
- python实现爬虫统计学校BBS男女比例(二)多线程爬虫
- 数据挖掘(二)用python实现数据探索:汇总统计和可视化
- 最小二乘回归树Python实现——统计学习方法第五章课后题
- 分组统计二
- 二、代码行数统计
- 《统计学习方法》笔记二
- 统计学习方法(二)
- 统计学习方法(二)
- 统计学习方法(二)
- baseAdapt getView 重复执行很对遍原因
- 黑马程序员—经典题目:兔子问题
- 欢迎使用CSDN-markdown编辑器
- SqlServer bug:sp_replqueuemonitor 在SqlServer 2008(RTM) 执行无结果
- Triangle DP求最大和
- python 统计pvuv 二
- android判断手机SIM状态
- Spark Core源码分析: RDD基础
- EditText 判断有没有获得焦点
- HttpClientUtil访问方式
- 【Oracle数据库技术支持】RAC性能分析 - gc buffer busy acquire 等待事件
- Pascal's Triangle
- 基于MATLAB中fft2函数的二维图像数据的频谱生成代码
- Best Time to Buy and Sell Stock 买卖