Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C50E19.4E45912A"
Hello all,
I am writing a program to take a data file, divide it up into columns and print the information back with headers. The data files looks like this
0.0 -3093.44908 -3084.59762 387.64329 26.38518 0.3902434E+00 -0.6024320E-04 0.4529416E-05
1.0 -3094.09209 -3084.52987 391.42288 105.55994 0.3889897E+00 -0.2290866E-03 0.4187074E-03
2.0 -3094.59358 -3084.88826 373.64911 173.44885 0.3862430E+00 -0.4953443E-03 0.2383621E-02
etc…
10.0 ...
So I wrote the program included below and it only prints the last line of the file.
Timestep PE
10.0 -3091.80609
I have one question. Do I need to put ts and pe into a list before I print then to screen or I am just missing something. Thanks.
Ara
import string
inp = open("fort.44","r")
all_file = inp.readlines()
inp.close()
outp = open("out.txt","w")
cols = map(string.split,all_file)
##print cols
Data = "">
for line in cols:
ts = line[0]
# print line[0]
pe = line[1]
# print line[1]
print """
Timestep PE"""
print "%s %s " % (ts,pe)
outp.close()
Put the print statement in the for loop.
for line in cols:
...
print "%s %s " % (ts,pe)
mailto:[EMAIL PROTECTED]
303 442 2625 home
720 938 2625 cell
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor