Ctrl K

μ-awk

This is a tiny Python implementation of a line processor with Awk-like semantics. You write a set of regex-based rules. The program loops through the lines of some input file, running the matching functions on lines that match.

1
contributor
Get started
14 commitsLast commit ≈ 5 months ago0 stars0 forks

Description

Who is this for?

μ-awk could be for you if you need a quick way to mangle some text files in Python, without writing a full blown parser. The main strength of μ-awk is that it has no dependencies except for Python itself.

We use μ-awk mainly for half-parsing Markdown files.

How to use

You derive a class from mawk.RuleSet where you decorate some of the methods with regular expressions. Those methods are then called whenever a matching line is encountered, giving you the opportunity to replace or amend the given line. This is more or less exactly how you would use a regular GNU Awk script, except now you have it with just over 150 lines of pure Python.

What it does not

μ-awk is not designed for performance.

Keywords
Programming language
  • Python 100%
License
</>Source code

Contributors

JH
Architect and developer
Netherlands eScience Center

Related software

Entangled

EN

Entangled makes literate programming easier. It keeps markdown and program source in sync. This makes it more convenient to extend and debug your literate code.

Updated 44 months ago
3 5