使用python重写上篇文章的内容分析工具
来源:互联网 发布:和日本人谈恋爱 知乎 编辑:程序博客网 时间:2024/06/05 20:21
import sys
import re
import time
def readfile():
information = []
count = 0
count1 = 0
fileDir = "c:/test.log"
#需要找到的关键字符串1
findString = "保存需求上报流程数据"
#需要找到的关键字符串2
findString1 = "计通[2015]66号《关于下发《基于全过程的管线资源建设管理要求》的通知》"
#遍历出一个大数组出来
for line in open(fileDir, encoding = 'gb2312'):
pattern = re.compile('[2]\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d')
match = pattern.match(line)
#如果找到了时间戳
if match:
count1 +=1
date = match.group()
item = [date,line]
information.append(item)
else:
information[len(information)-1][1] = information[len(information)-1][1] + line
count += 1
#下面开始找字符串
resultCount = 0
for a in information:
if boolFindTxt(a[1], findString):
if boolFindTxt(a[1],findString1):
print(a[1])
resultCount += 1
print ("line total:",count)
print ("Time stamp matched ",count1)
print ("result line total: ", resultCount)
#从一个字符串中找到txt
def boolFindTxt(line, txt):
result = line.find(txt)
if result == -1:
return False
else:
return True
start = time.clock()
readfile()
end = time.clock()
print ("read:{} s".format(end -start))
import re
import time
def readfile():
information = []
count = 0
count1 = 0
fileDir = "c:/test.log"
#需要找到的关键字符串1
findString = "保存需求上报流程数据"
#需要找到的关键字符串2
findString1 = "计通[2015]66号《关于下发《基于全过程的管线资源建设管理要求》的通知》"
#遍历出一个大数组出来
for line in open(fileDir, encoding = 'gb2312'):
pattern = re.compile('[2]\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d')
match = pattern.match(line)
#如果找到了时间戳
if match:
count1 +=1
date = match.group()
item = [date,line]
information.append(item)
else:
information[len(information)-1][1] = information[len(information)-1][1] + line
count += 1
#下面开始找字符串
resultCount = 0
for a in information:
if boolFindTxt(a[1], findString):
if boolFindTxt(a[1],findString1):
print(a[1])
resultCount += 1
print ("line total:",count)
print ("Time stamp matched ",count1)
print ("result line total: ", resultCount)
#从一个字符串中找到txt
def boolFindTxt(line, txt):
result = line.find(txt)
if result == -1:
return False
else:
return True
start = time.clock()
readfile()
end = time.clock()
print ("read:{} s".format(end -start))
0 0
- 使用python重写上篇文章的内容分析工具
- 可执行文件的内容分析工具
- 上篇文章影响到整个页面的显示
- 使用python制作简单的日志以及日志分析工具
- Python中cProfile性能分析工具的使用
- FMDB的使用,比较上篇文章一起学习,应该就会了
- Apache Tika:通用的内容分析工具
- Apache Tika:通用的内容分析工具
- Apache Tika:通用的内容分析工具
- Tika通用的内容分析工具
- XML的增删改 其人 上篇文章 文章分页 值得一看
- 浅谈Jquery的使用上篇
- 使用Python工具分析风险数据 20160723
- python性能分析工具:cProfile使用
- 代立东-----使用MAT分析内存泄露【还有其他文章都是BigData优化方面的内容,很有用】
- 安装和使用IIS的URL重写工具
- 语义分析的一些方法(上篇)
- 语义分析的一些方法(上篇)
- webdriver UI自动化测试执行JS脚本
- vc中关闭对话框dialog
- KING_UNITY学习之鼠标点击地面控制人物移动
- LeetCode 144:Binary Tree Preorder Traversal
- qpixmap 鼠标移动,局部放大
- 使用python重写上篇文章的内容分析工具
- range,hash,list分区
- php【基础学习七】string操作
- Android中string资源文件使用技巧
- css 文字长时不换行 显示...
- 周记——20151221
- List is a raw type. References to generic type List<E> should be parameterized
- 我希望的Golang的feature
- 总结学习VS2010的dll的创建与调用