[Tutor] One more (sorry)

kevin parks kp87@lycos.com
Sat, 09 Feb 2002 20:36:31 +0900


One of the things that I have to do over and over again is read in a file and fondle one or more of the parameters. So if i have a file that looks like this:

foo  1.0  5.0  10.0
foo2 1.0  5.0  15.0
foo  2.5  3.0  9.00
foo  3.1  5.5  12.00
foo3 5.0  1.25 7.00

and i want to add .5 to all of foo's column 2 to get:

foo  1.5  5.0  10.0
foo2 1.0  5.0  15.0
foo  3.0  3.0  9.00
foo  3.6  5.5  12.00
foo3 5.0  1.25 7.00

or add 1.1 too all of foo2's column 4 to get:

foo  1.0  5.0  10.0
foo2 1.0  5.0  16.1
foo  2.5  3.0  9.00
foo  3.1  5.5  12.00
foo3 5.0  1.25 7.00

How would I do that? Could anyone show me an example of how that is done in python? I usually use a Cshell script for that, but I don't have a csh now as my OS X partition is gone. Besides I would really love to learn how to do this in Python so that i don't have to try to remember where to put all my $ and such in csh anymore!

cheers,

kevin





Go Get It!
Send FREE Valentine eCards with Lycos Greetings
http://greetings.lycos.com