<!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.7638.1">
<TITLE>Generating text files (newbie)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Assume I have a tab-delimited text file called foo.txt organized as follows:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">x11 -0.04 </FONT>
<BR><FONT SIZE=2 FACE="Arial">x22 -0.42 </FONT>
<BR><FONT SIZE=2 FACE="Arial">x33 0.3</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">My goal is to read in this file and use the information therein to output a new file that is organized as follows:</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">x11 IRM=3PL IPB= -0.04 </FONT>
<BR><FONT SIZE=2 FACE="Arial">x22 IRM=3PL IPB= -0.42 </FONT>
<BR><FONT SIZE=2 FACE="Arial">x33 IRM=3PL IPB= 0.3</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">I am a newbie with python and am trying to put the pieces together. Now, I know if I had a list, I could do something like:</FONT></P>
<P><FONT SIZE=2 FACE="Arial">a = [-0.04, -0.42, 0.3]</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">>>> for i in a:</FONT>
<BR> <FONT SIZE=2 FACE="Arial">print "IRM = 3PL", "\t", "IPB = ", i</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">IRM = 3PL IPB = -0.04</FONT>
<BR><FONT SIZE=2 FACE="Arial">IRM = 3PL IPB = -0.42</FONT>
<BR><FONT SIZE=2 FACE="Arial">IRM = 3PL IPB = 0.3</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">And then I could write this to a file. But I am not sure how to I might tackle this when I read in a text file. </FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">So far, my basic skills allow for me to accomplish the following</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"># read in file</FONT>
<BR><FONT SIZE=2 FACE="Arial">params = open('foo.txt', 'r+')</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"># Write to the file</FONT>
<BR><FONT SIZE=2 FACE="Arial">params.write('Add in some new test\n')</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">params.close()</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Any pointers are appreciated. I'm using python 2.3 on a windows xp machine.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks.</FONT>
</P>
</BODY>
</HTML>