Metadata-Version: 2.1
Name: awkupy
Version: 0.1.0b0
Summary: A simple Python interface and IPython/Jupyter magic for AWK
Home-page: https://github.com/ashwinvis/awkupy
Author: Ashwin Vishnu Mohanan
Author-email: ashwinvis+gh@protonmail.com
License: GPL-3.0-or-later
Keywords: awk,iawk,cli,IPython,Jupyter
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Awk
Classifier: Framework :: IPython
Classifier: Framework :: Jupyter
Classifier: Topic :: Text Processing :: General
Description-Content-Type: text/markdown
Requires-Dist: ipython (>=6.0)
Requires-Dist: typing ; python_version < "3.6"
Requires-Dist: dataclasses ; python_version < "3.7"
Provides-Extra: dev
Requires-Dist: sphinx ; extra == 'dev'
Requires-Dist: recommonmark (>=0.5.0) ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme (==0.4.3) ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: jupyter ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: wheel ; extra == 'dev'
Requires-Dist: readme-renderer[md] (==24.0) ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Requires-Dist: recommonmark (>=0.5.0) ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme (==0.4.3) ; extra == 'docs'

awkupy and IAwk
===============
*AWK meets Python: API, CLI and magics*

[![PyPI](https://img.shields.io/pypi/v/awkupy)](https://pypi.org/project/awkupy/)
[![LICENSE](https://img.shields.io/badge/license-GPL-blue.svg)](/LICENSE)

A simple subprocess based Pythonic interface for Awk, which powers a
command-line REPL and Jupyter magics.


Installation
------------

```bash
pip install awkupy
```

Features
--------

- [x] Python class to call AWK via subprocess - see an [example](doc/examples/coins_histogram.py).
- [x] IPython / Jupyter magics: `%awk` and `%%awk`, enabling polyglot
      programming with Awk. See [example](doc/examples/coins_histogram.ipynb)
      and the [tutorial](doc/examples/tutorial.ipynb) for more details.

```awk
In [1]: %load_ext iawk

In [2]: cd doc/examples/
/home/avmo/src/projects/awkupy/doc/examples

In [3]: %%awk --stdout coins.txt
   ...: {
   ...:   country[$4]++
   ...: }
   ...:
   ...: END {
   ...:   for (i in country) print "Country: " i," count: ", country[i]
   ...: }
   ...:
   ...:
Country: USA  count:  7
Country: PRC  count:  1
Country: Austria-Hungary  count:  1
Country: Canada  count:  1
Country: Switzerland  count:  1
Country: RSA  count:  2
```

- [x] IAwk: interactive AWK prompt modelled after IPython.

```awk
❯❯❯ iawk                                                                                                                                        (awkupy)
Welcome to the IAwk shell. Type help or ? to list commands.
Prefix ! to run system commands

iawk [1]: help

Documented commands (type help <topic>):
========================================
EOF  cd  exit  help  hist  history  input  ls  reset  run  set  shell  show

iawk [2]: cd doc/examples/
doc/examples/
iawk [3]: ls
coins.txt coins_histogram.py coins_histogram.awk
iawk [4]: set pattern /gold/
iawk [5]: set action print $0
iawk [6]: input coins.txt
iawk [7]: show
#!/usr/bin/awk -f
/gold/ {print $0}

iawk [8]: run
iawk [9]:    gold     1    1986  USA                 American Eagle
   gold     1    1908  Austria-Hungary     Franz Josef 100 Korona
   gold     1    1984  Switzerland         ingot
   gold     1    1979  RSA                 Krugerrand
   gold     0.5  1981  RSA                 Krugerrand
   gold     0.1  1986  PRC                 Panda
   gold     0.25 1986  USA                 Liberty 5-dollar piece
   gold     0.25 1987  USA                 Constitution 5-dollar piece
   gold     1    1988  Canada              Maple Leaf

iawk [9]: exit
```

References
----------

- [To awk or not to ...](https://sites.google.com/site/toawkornot/home) -
  excellent tutorial on Awk


