Code Directory
 Visual Basic & VB.NET
New Code
Vue Injector 3.3
Spectrum Analyzer pro Live 2019
Devart Excel Add-in for HubSpot 2.1
RentALLScript - Airbnb clone 2.2
SuiteCRM Theme Customization 7.11.6
iScripts NetMenus 3.1
iScripts EasyIndex 2.2
iScripts EasySnaps 2.0
Australia MyPost shipping For Magento 2 1.0.0
Australia Post eParcel For Magento 1.1.1
Source Control for SQL Server 2.0
Answers phpSoftPro 3.12
Exlcart 2.0
School College ERP 1.3.2
White-label Grocery Delivery App Solution 2.0
Top Code
IcrediBB Bulletin Board System 1.0
MATLAB Support Package for Arduino (aka ArduinoIO Package) 1.0
Azizi search engine script PHP 4.1.10
Binary MLM Plan 1.0.2
Answers phpSoftPro 3.12
Low Pass Butterworth Filter 1.0
The Shakespeare Programming Language 1.0
Faculty Evaluation System 1.1
MLM Binary Plan Script – i-Netsolution 1.0.2
MLM Software ONE 1.5.46
Online Food Ordering System 1.3.2
Cuckoo Optimization Algorithm 1.0
Java-2-Pseudo 1.0
Vue Injector 3.3
Top Rated
Uber Clone with Safety Measure Addons 2.0
Answers phpSoftPro 3.12
phpEnter 5.1.
Quick Maps For Dynamics CRM 3.1
Single Leg MLM 1.2.1
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
Deals and Discounts Website Script 1.0.2
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
Line-oriented processing in Python from command line (like AWK) 
File ID: 64428

Line-oriented processing in Python from command line (like AWK) 
Download Line-oriented processing in Python from command line (like AWK) Error Link
License: Freeware
Downloads: 17
Submit Rating:
Line-oriented processing in Python from command line (like AWK)  Description
Description: A very simple but powerful shell script which enables writing ad-hoc Python scripts for processing line-oriented input. It executes the following code template:

for line in sys.stdin:

where $INIT, $LOOP and $END code blocks are given from command line. If only one argument is given, then $INIT and $END are empty. If two arguments are given, $END is empty.

Examples (script is saved as 'pyk' in the $PATH):

"wc -l" replacement:
$ cat file | pyk 'c=0' 'c+=1' 'print c'
grep replacement:
$ cat file | pyk 'import re' 'if"d+", line): print line'
adding all numbers:
$ seq 1 10 | pyk 's=0' 's+=int(line)' 'print s'
prepending lines with it's length:
$ cat file | pyk 'print len(line), line'
longest file name:
$ ls -1 | pyk 'longest=""' 'if len(line) > len(longest): longest=line' 'print longest'
number of unique words in a document:
$ pyk 'words=[]' 'words.extend(line.split())' 'print "All words: {}, unique: {}".format(len(words), len(set(words))'

License: Freeware

Related: Awk, bash, Python, Shell


Downloads: 17

More Similar Code

State machine for processing text files on a line-by-line basis using regular
expressions to determine transition to next state.

Developed from sample code from "Text Processing in Python" by David Mertz,pp. 274-280.

Underpin is a simple command line utility written in Python that allows developers to generate new projects from customizable templates.

It is a command-line program written in Python which helps converting file between different formats types.Note: Internet connection is required.

it is an application that produces tables HTML format both from command line both away cgi withdrawing the data from a MySQL database

OutMan (short for OUTput MANager) manages output from command line based tools (such as make or grep).

Project contains a small set of tools that will help people with 7zip when working from command line (batch files). There are not general purpose tools like 7z.exe from the orginal project, but they are very specific, lean implementation.

You specify a desired domain-logic in UML, optionally some parts in Python, from scratch or reused. This custom application model is dynamically executed or updated. - Aeonic is a project to develop that kind of MDD technology for modern server apps.

This module allows one to create a command to call a Python function from the command line, and to call that function with arguments from the command line without using getopt or optparse

ctioga2 is a polymorphic non-interactive plotting program. It can be driven both completely from command-line and through the use of command files. It is based on the Tioga plotting library, and produces PDF graphs of very high quality.

Java command line parser based on annotations. Aims to minimize the effort needed to set up a Java program from command line arguments.

User Review for Line-oriented processing in Python from command line (like AWK)
- required fields

Please enter text on the image