{ "info": { "author": "Thamme Gowda", "author_email": "tgowdan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3", "Topic :: Text Processing", "Topic :: Text Processing :: Filters", "Topic :: Text Processing :: General", "Topic :: Utilities" ], "description": "# awkg\n\n`awkg` is an `awk` like utility using modern day python language.\n`awk` is amazingly simple, fast and quite handy. However, its domain specific constrain \nsometimes get in our way. `awkg` follows the steps of `awk`'s design (including its convention for name\ud83d\ude09)\nand exposes full power of the modern day python. \nPython's large set of off-the-shelf existing libraries can of course be imported and used. \n\n# Installation \n```bash\n\n# Install from pypy \n$ pip install awkg\n\n# Install from github\n$ pip install git+https://github.com/thammegowda/awkg.git\n\n```\n\n# CLI usage: \n\n```\n$ awkg -h \nusage: awkg [-h] [-i INP] [-o OUT] [-F FS] [-OFS OFS] [-ORS ORS]\n [-b BEGIN_SCRIPT] [-e END_SCRIPT] [-im IMPORTS] [-it INIT_PATH]\n [-v]\n inline_script\n\nawkg is an awk-like text-processing tool powered by python language\n\npositional arguments:\n inline_script Inline python script\n\noptional arguments:\n -h, --help show this help message and exit\n -i INP, --inp INP Input file path; None=STDIN\n -o OUT, --out OUT Output file path; None=STDOUT\n -F FS, -FS FS, --field-sep FS\n the input field separator. Default=None implies white\n space\n -OFS OFS, --out-field-sep OFS\n the out field separator. Default=None implies same as\n input FS.\n -ORS ORS, --out-rec-sep ORS\n the output record separator. Default=None implies same\n as input RS.\n -b BEGIN_SCRIPT, --begin BEGIN_SCRIPT\n BEGIN block. initialize variables or whatever\n -e END_SCRIPT, --end END_SCRIPT\n END block. Print summaries or whatever\n -im IMPORTS, --import IMPORTS\n Imports block. Specify a list of module names to be\n imported.Semicolon (;) is the delimiter. Ex:\n json;numpy as np\n -it INIT_PATH, --init INIT_PATH\n The rc file that initializes environment.Default is\n $HOME/.awkg.py\n -v, --version show program's version number and exit\n\n```\n# Example\n\n### Compute mean and std of words per sequence\n```bash\n\ncat data/train.src | awkg -b 'arr=[]; import numpy as np' 'arr.append(NF)' \\\n -e 'arr=np.array(arr); print(f\"{NR} lines from {FNAME}, mean={arr.mean():.2f}; std={arr.std():.4f}\")'\n```\n### Filter records\n```\n# use print() explicitely \ncat data/train.src | awkg 'if NF >= 25: print(*R)' \n\nAssign boolean expression to special variable RET to trigger implicit print \ncat data/train.src | awkg 'RET = NF >= 25'\n\n# print respects the OFS value\ncat data/train.src | awkg 'if NF >= 25: print(NR, NF)' -OFS='\\t'\n```\n\n## Special Variables\n+ `NF` : Number of fields\n+ `NR` : Record number \n+ `R` : An array having all the columns of current record.\n+ `R0` : analogous to `$0` it stores the input line before splitting into `R`; since python does\n not permit `$` in the identifiers, it is renamed as `R0`\n+ `RET` : When this variable is set to Truth value of `true` implicit `print(*R)` is triggered\n+ `FS` : Input Field separator\n+ `OFS` : Output Field separator; Unless explicitly set, `OFS=FS`\n+ `ORS` : Output Record separator\n+ `RS` (Currently Not in use)\n+ `_locals` , `_globals` - all variables in local and global scope\n\nYou are allowed to use any valid python identifiers, than the above variables\n\n## Default import modules \nThese modules are imported by default\n+ `sys`\n+ `os`\n+ `re`\n+ `from pathlib import Path`\n\n\n## Author:\n+ [Thamme Gowda](https://twitter.com/thammegowda)\n\n## Related tools\n+ [pawk](https://github.com/alecthomas/pawk) similar to this repository, slightly different implementation.\n+ [gawk](https://www.gnu.org/software/gawk/manual/gawk.html) GNU awk\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/thammegowda/awkg", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thammegowda/awkg", "keywords": "", "license": "GNU General Public License v3 (GPLv3)", "maintainer": "", "maintainer_email": "", "name": "awkg", "package_url": "https://pypi.org/project/awkg/", "platform": "any", "project_url": "https://pypi.org/project/awkg/", "project_urls": { "Download": "https://github.com/thammegowda/awkg", "Homepage": "https://github.com/thammegowda/awkg" }, "release_url": "https://pypi.org/project/awkg/0.3.0/", "requires_dist": null, "requires_python": ">=3.5", "summary": "awkg is an awk-like text-processing tool powered by python language", "version": "0.3.0" }, "last_serial": 5621158, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "daf769a5947137d200a5ad7056a00e4a", "sha256": "d47c730d50a4f00cb4f73dadba21feffad4de4a406fe5bd13027b7555670a8dd" }, "downloads": -1, "filename": "awkg-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "daf769a5947137d200a5ad7056a00e4a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 6057, "upload_time": "2019-07-23T02:28:01", "url": "https://files.pythonhosted.org/packages/2a/33/567af991d27f607b6a3a83b97bb24f2aeeb25a6f24650d020a57525085d8/awkg-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fbeed47c4c06dc385c3be1f1da4c6298", "sha256": "ee35c573afd0a51070c1525b432176f58da2fd31e766c31c876f9b937ee41975" }, "downloads": -1, "filename": "awkg-0.1.2.tar.gz", "has_sig": false, "md5_digest": "fbeed47c4c06dc385c3be1f1da4c6298", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5362, "upload_time": "2019-07-23T02:28:02", "url": "https://files.pythonhosted.org/packages/99/dc/eff19be8149caa36a50496618995617318e243ffab82c9da0e4682ac65b1/awkg-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6ec3ae9da42cfa14b5c679409986b57f", "sha256": "dfe2e61fd3e4c4faec4ccbd58f0ed2335d79af7e31c5b78a786c90111c6d8c19" }, "downloads": -1, "filename": "awkg-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6ec3ae9da42cfa14b5c679409986b57f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 18306, "upload_time": "2019-07-24T00:01:42", "url": "https://files.pythonhosted.org/packages/ba/bb/6903904abc9d12d6f9e1e18f3eb75a4fc0885f3d742faf0e887920e8ce2c/awkg-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e38611e0097ee9fc11825eded9f47fb", "sha256": "83588caa563df6fbba2f9f81eec21884722f0871628d96e34d9ad8870f1ea30f" }, "downloads": -1, "filename": "awkg-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0e38611e0097ee9fc11825eded9f47fb", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5338, "upload_time": "2019-07-24T00:01:43", "url": "https://files.pythonhosted.org/packages/fe/ec/6f99cf69c34a183a28b143b2433e2c33b2e59b5a648cbdfdba13b3c51ec4/awkg-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "097e031099cab120b595f69d631a21bb", "sha256": "5b42363a4975ca4607ff154a6abd9a94e08dfc70d5ce47376d10afc100f4839c" }, "downloads": -1, "filename": "awkg-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "097e031099cab120b595f69d631a21bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 18313, "upload_time": "2019-08-01T22:52:06", "url": "https://files.pythonhosted.org/packages/1d/9d/ccbca7caea2b2b9c0b09e6b2698643daa447ea3f90b460169ae23c0c0daa/awkg-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4085db218d59b3effead700c35ecd71b", "sha256": "c0d5da9ef06a4aa588537c8c5e0565da2c73ee7be98cc32b468d092cadce91f3" }, "downloads": -1, "filename": "awkg-0.3.0.tar.gz", "has_sig": false, "md5_digest": "4085db218d59b3effead700c35ecd71b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5346, "upload_time": "2019-08-01T22:52:08", "url": "https://files.pythonhosted.org/packages/5f/43/7490109172a0f2a1ec0e6a6a411b27b7758feec43cc4f97c30da9b665adf/awkg-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "097e031099cab120b595f69d631a21bb", "sha256": "5b42363a4975ca4607ff154a6abd9a94e08dfc70d5ce47376d10afc100f4839c" }, "downloads": -1, "filename": "awkg-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "097e031099cab120b595f69d631a21bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 18313, "upload_time": "2019-08-01T22:52:06", "url": "https://files.pythonhosted.org/packages/1d/9d/ccbca7caea2b2b9c0b09e6b2698643daa447ea3f90b460169ae23c0c0daa/awkg-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4085db218d59b3effead700c35ecd71b", "sha256": "c0d5da9ef06a4aa588537c8c5e0565da2c73ee7be98cc32b468d092cadce91f3" }, "downloads": -1, "filename": "awkg-0.3.0.tar.gz", "has_sig": false, "md5_digest": "4085db218d59b3effead700c35ecd71b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5346, "upload_time": "2019-08-01T22:52:08", "url": "https://files.pythonhosted.org/packages/5f/43/7490109172a0f2a1ec0e6a6a411b27b7758feec43cc4f97c30da9b665adf/awkg-0.3.0.tar.gz" } ] }