Using Python as awk alternative
Project description
awpie
Using Python as awk alternative.
Installation
$ pip install awpie
Usage
Upper case all inputs:
$ printf 'apple\norange\n' | awpie 'print(line.upper())'
APPLE
ORANGE
Change orange to banana:
$ printf 'apple\norange\n' | awpie 'print(line) if line != "orange" else print("banana")'
apple
banana
Local variables
Name | Description |
---|---|
line |
Current line. |
fields |
Result of line.split() . |
data |
An empty dict, can be used to store custom values. |
stdout |
sys.stdout . |
stderr |
sys.stderr . |
filename |
Name of the file currently being read. |
fileno |
File descriptor for the current file. |
lineno |
Cumulative line number of the line that has just been read. |
filelineno |
Line number in the current file. |
isfirstline |
Whether the line just read is the first line of its file or not. |
isstdin |
Whether the last line was read from sys.stdin or not. |
nextfile |
Close current file so that next iteration will be read from next file. |
close |
Close the sequence. |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
awpie-0.3.0.tar.gz
(2.6 kB
view details)
Built Distribution
awpie-0.3.0-py3-none-any.whl
(3.1 kB
view details)
File details
Details for the file awpie-0.3.0.tar.gz
.
File metadata
- Download URL: awpie-0.3.0.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c0c9f91e0acdd838bd7d73577fc1f4c1b79b0f43dc3bdcea7db008fc6f28d8 |
|
MD5 | 5f5211b718c805990757e2e4bd564a1c |
|
BLAKE2b-256 | a718ce5ffb6da0dade2718564d3fa175d680c532e205150466bde5858d659dd5 |
File details
Details for the file awpie-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: awpie-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5586ba04ba30913794e1cce169ee713d8de3c8c8e8cca096c7b21da5d1a463db |
|
MD5 | c70abf1820e326d952608b2e62bdf93a |
|
BLAKE2b-256 | dceead27cafebb64a6b3ca828ff3482276671d9a43abc0c3a84ac1f9779f2279 |