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(sep) . sep can be specified in arguments. |
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.4.0.tar.gz
(2.9 kB
view details)
Built Distribution
awpie-0.4.0-py3-none-any.whl
(3.4 kB
view details)
File details
Details for the file awpie-0.4.0.tar.gz
.
File metadata
- Download URL: awpie-0.4.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea8f8cfbe966754b9a7bd83e8a6629568a94302e343d78d41d349ce07602184e |
|
MD5 | a1c63ed2ccb1e01e5700347221cf1805 |
|
BLAKE2b-256 | 4857ed072fe1f4a1d5ce4ee0459cf21e2fa4ef801678376d35ea7322a45e5c70 |
File details
Details for the file awpie-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: awpie-0.4.0-py3-none-any.whl
- Upload date:
- Size: 3.4 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 | 6cf1c0dba1fff671b9d2d73a0cb4a53380cd745bb62682d04f0d50e54ded2d2d |
|
MD5 | c92d96ff851a44fb17f9ef137d024daa |
|
BLAKE2b-256 | 3b35d52233cee7a0442b7cf8379b6d10f9df234f7cd6e4d87475c2262c17a8bf |