--- id: pygrok version: "1.0.0" license: MIT license_treatment: permissive maintenance: dormant --- # pygrok — A Python library to parse strings and extract information from structured/unstructured data License: permissive · Maintenance: dormant · Downloads: 98.4K/mo ## What it is and what it does pygrok is a Python library that implements Grok-style pattern matching for parsing and extracting data from strings. Instead of writing complex regular expressions, you define patterns using named capture groups like `%{WORD:name}` and `%{NUMBER:age:int}`, and the library handles the underlying regex matching. It comes with a library of pre-built patterns for common data types (IP addresses, timestamps, log formats, etc.) and supports type conversion during extraction. The package is built on top of the regex module (not Python's built-in re) because it needs atomic grouping syntax that the standard library doesn't support. It's most useful for log parsing, structured data extraction from semi-formatted text, and situations where you want readable, maintainable pattern definitions instead of dense regex strings. Use it for: - Parse application or system logs to extract fields like timestamps, log levels, and messages into structured records. - Extract key-value pairs from semi-structured text (e.g., 'name is gary, age 25') without hand-writing regex. - Convert matched string values to specific types (int, float) during extraction in a single step. - Build data pipelines that need to normalize and structure incoming text data before storage or analysis. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Parses strings and extracts structured data using Grok patterns, a named-capture syntax that simplifies pattern matching without writing complex regular expressions. No. The package is dormant (last release 2016-09-24, no activity since 2023-11-22) and has high install friction due to the regex module dependency. While it solves a real problem, the lack of maintenance and Python version uncertainty make it risky for new projects. Consider active alternatives like regex-based parsing libraries or modern log-parsing frameworks. ## Install pip install pygrok uv add pygrok poetry add pygrok ## Installing pygrok Before you install: High install friction: the package is dormant (last release 2016-09-24, no commits since 2023-11-22) and requires the regex module as a runtime dependency, which may have compilation requirements on some systems. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install pygrok from pygrok import Grok text = 'gary is male, 25 years old and weighs 68.5 kilograms' pattern = '%{WORD:name} is %{WORD:gender}, %{NUMBER:age:int} years old and weighs %{NUMBER:weight:float} kilograms' grok = Grok(pattern) result = grok.match(text) print(result) # {'name': 'gary', 'gender': 'male', 'age': 25, 'weight': 68.5} The regex module must be installed and may require a C compiler on some platforms; Python version compatibility is unspecified. Verify before relying: - Whether the regex module dependency is pre-compiled or requires a C compiler on your platform. - Python version compatibility: requires_python is unspecified in the fact sheet. - Whether dormancy affects real-world reliability for production log parsing workloads. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: high - Maintenance: dormant - Downloads: 98.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags grok pattern parsing, extract data from logs, named regex patterns, parse unstructured text, string pattern matching, log parsing library, structured data extraction, log-parsing, pattern-matching, data-extraction [View on SkillFed](https://skillfed.io/packages/pygrok) · [View on PyPI](https://pypi.org/project/pygrok/)