Code Directory
 Visual Basic & VB.NET
New Code
.Net VCL for Delphi
ASP. NET C# PDF Software 4.5
LinqConnect Professional 4.8
CAD VCL: 2D/3D CAD in Delphi/C++Builder 14
wolfSSL 3.15.7
AnyStock Stock and Financial JS Charts 8.4.2
ODBC Driver for SQLite 2.4
dotConnect for SugarCRM 1.7
dbForge SQL Complete 5.9
dbForge Studio for MySQL 8.0
.Net Runtime Library for Delphi
Scimbo 1.64
AnyMap JS Maps 8.4.2
GetOrgChart 2.5.3
Top Code
Issue Manager App 1.0
i-Net School Management Script 1.0.4
Online Vacation Rental Booking Website Script 4.3.0
Hotel Management - Full Board Version 6.55
Simple Hill-Climbing 1.0
Ticket Booking System 1.0
College Management System Script 1.0.4
Skincare Management System 1.4
Library Management System 1.0
Faculty Evaluation System 1.1
.Net VCL for Delphi
ASP. NET C# PDF Software 4.5
MATLAB Support Package for Arduino (aka ArduinoIO Package) 1.0
MCU 8051 IDE 1.4.7
CPP-2-HTML CSS Source Code Tagger 1.02
Top Rated
Paste phpSoftPro 1.4.1
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
PHP GZ Blog Script 1.1
ATN Jobs Software 4.0
ATN Mall 2.0
WeBuilder 2015 13.3
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: 11
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: 11

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