用于解析字符串和从结构化/非结构化数据中提取信息的python库

yalp_grok的Python项目详细描述


Build StatusCoverage StatusDependency StatusPyPi version

https://github.com/garyelephant/pygrok分叉,因为它好像死了。如果 Pygrok再次激活此分叉可能已关闭。

jordan sissel的grok的python实现。

安装

pip install yalp_grok

基本用法

>>>importyalp_grokaspygrok>>>text='gary is male, 25 years old and weighs 68.5 kilograms'>>>pattern='%{WORD:name} is %{WORD:gender}, %{NUMBER:age} years old andweighs%{NUMBER:weight}kilograms'>>>printpygrok.grok_match(text,pattern){'gender':'male','age':'25','name':'gary','weight':'68.5'}

重复使用模式

由于编译一个模式可能很耗时,因此可以编译一次模式 然后重新用于搜索。

>>>importyalp_grokaspygrok>>>pattern="%{COMMONAPACHELOG}">>>compiled_pattern=pygrok.compile_pattern(pattern)>>>withopen('/var/log/apache/access.log','r')aslog_file...matches=[pygrok.grok_search(line,compiled_pattern)forlineinlog_file]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓 java。lang.NullPointerException:uriString   如何使IntelliJ IDEA支持Java 7功能?   如何最好地将这个java方法翻译成python   eclipse java。lang.IllegalStateException:设置后无法更改位置   java连接超时在HttpClient中不起作用   java在Eclipse中添加JPA连接   java我需要帮助来构建一个返回数组的方法   c#从Internet Explorer 8中的ActiveX控件中提取数据   java使用varargs传递参数对,而不会遇到错误模式   java使用jQuery读取txt文件时无法返回函数外的值   ApachePOI如何在Java中获取“last saved by”Office文件属性   to date JavaTo_date()在可调用语句中   向maven添加依赖项时出现java问题   java Selenium服务器,在ASP中单击定位器。NET网页工作不稳定