<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>Printing columns of data</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hello all,</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> 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</FONT></P>
<P><FONT SIZE=2 FACE="Courier New"> 0.0 -3093.44908 -3084.59762 387.64329 26.38518 0.3902434E+00 -0.6024320E-04 0.4529416E-05</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> 1.0 -3094.09209 -3084.52987 391.42288 105.55994 0.3889897E+00 -0.2290866E-03 0.4187074E-03</FONT>
<BR><FONT SIZE=2 FACE="Courier New"> 2.0 -3094.59358 -3084.88826 373.64911 173.44885 0.3862430E+00 -0.4953443E-03 0.2383621E-02</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">etc…</FONT>
<BR> <FONT SIZE=2 FACE="Courier New">10.0 ...</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">So I wrote the program included below and it only prints the last line of the file.</FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">Timestep PE</FONT>
<BR><FONT SIZE=2 FACE="Courier New">10.0 -3091.80609 </FONT>
</P>
<P><FONT SIZE=2 FACE="Courier New">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.</FONT></P>
<P><FONT SIZE=2 FACE="Courier New">Ara</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">import string</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">inp = open("fort.44","r")</FONT>
<BR><FONT SIZE=2 FACE="Arial">all_file = inp.readlines()</FONT>
<BR><FONT SIZE=2 FACE="Arial">inp.close()</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">outp = open("out.txt","w")</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">cols = map(string.split,all_file)</FONT>
<BR><FONT SIZE=2 FACE="Arial">##print cols</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Data = {}</FONT>
<BR><FONT SIZE=2 FACE="Arial">for line in cols:</FONT>
<BR><FONT SIZE=2 FACE="Arial"> ts = line[0]</FONT>
<BR><FONT SIZE=2 FACE="Arial"># print line[0]</FONT>
<BR><FONT SIZE=2 FACE="Arial"> pe = line[1]</FONT>
<BR><FONT SIZE=2 FACE="Arial"># print line[1]</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">print """</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Timestep PE"""</FONT>
<BR><FONT SIZE=2 FACE="Arial">print "%s %s " % (ts,pe)</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">outp.close()</FONT>
</P>
</BODY>
</HTML>