Skip to main content

A framework which makes you to write scripts as if they were written in awk.

Project description

All you have to do is make a script file and create a class which extends PyAwk class and write some procedures like awk.

There are some examples on


  • Python 3.3 or later


  • begin and end syntax which are called only once in an execution.
  • begin_file and end_file syntax which are called only once par each file.
  • awk specific valiables like FILENAME, FS, OFS, RS, ORS, NF, NR, FNR, FIELDWIDTHS.
  • command line options like debug mode, set valiables.
  • SQLite3 query.


$ pip install PyAwk


0.1.0 (2014-02-21)

  • first release


This is a parser for LTSV formatted data.

#!/usr/bin/env python3.3
from pyawk import PyAwk, p
class LTSVParser(PyAwk):
    def begin(self):
        self.FS = '\t'
        self.count = 0

    def action(self, S):
        if not p(S[0], r'status:200'):
            self.count += 1
            d = {}
            for elem in S[1:]:
                key, value = elem.split(':', 1)
                d[key] = value

    def end(self):

if __name__ == '__main__':

Then you can execute this script with LTSV file.

$ ./ ltsv.log

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PyAwk, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size PyAwk-0.1.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page