Author: Keith Evans
Date: 21:32:17 08/10/04
Go up one level in this thread
I like to use awk for this sort of thing. You can get it you install cygwin, or
just look for the "One true awk" on Kernighan's page if you don't want all of
the extra features that gawk added.
Put the following into column.awk:
BEGIN {
FS = ","
}
// {
if ($2 == last_column2)
counter++
else
counter = 1
print $0 "," counter
last_column2 = $2
}
Then just run:
awk -f column.awk < source.txt > result.txt
If you ever get the chance check out the book "The AWK Programming Language" by
Aho, Kernighan, and Weinberger. It's a little pricey but a classic.
Alternatively download the gawk manual and or reference card.
If you like awk and need help just try posting on comp.lang.awk and with
examples like the one that you gave you should get a really quick response.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.