[Tutor] Data format question

Kooser, Ara S askoose at sandia.gov
Wed Jul 7 21:23:34 CEST 2004


   I am writing a filter program that reads a column of data, converts it
and then writes it to another file. I was wondering how do you convert a
column of data (for example multiply the column by a number or replace the
letter A with a number) and how does one maintain a column format in the new
output file? Also any suggested readings either on-line or books on text
file handling in Python would be appreciated. I have read through some of
the tutorials on python.org and read the python grimore. Thanks.


Here is a part of the code for pulling out a column of data and then writing
it to new file.

inp = open("out.txt","r")
outp = open("out2.txt","w")

for line in inp.readlines():
    words = line.split()      #thanks to orbitz for this line
    if len(words) >= 1: 

"There is something to be learned from a rainstorm. When meeting with a
sudden shower, you try not to get wet and run quickly along the road. But
doing such things as passing under the eaves of houses, you still get wet.
When you are resolved from the beginning, you will not be perplexed, though
you still get the same soaking." - Yamamoto Tsunetomo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040707/7e88dce8/attachment.htm

More information about the Tutor mailing list