<!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>Beginner question on text processing</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">I am beginning to use python primarily to organize data into formats needed for input into some statistical packages. I do not have much programming experience outside of LaTeX and R, so some of this is a bit new. I am attempting to write a program that reads in a text file that contains some values and it would then output a new file that has manipulated this original text file in some manner.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">To illustrate, assume I have a text file, call it test.txt, with the following information:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">X11     .32</FONT>

<BR><FONT SIZE=2 FACE="Arial">X22     .45</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">My goal in the python program is to manipulate this file such that a new file would be created that looks like:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">X11     IPB = .32</FONT>

<BR><FONT SIZE=2 FACE="Arial">X22     IPB = .45</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Here is what I have accomplished so far.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">##### Python code below for sample program called 'test.py'</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial"># Read in a file with the item parameters</FONT>

<BR><FONT SIZE=2 FACE="Arial">filename = raw_input("Please enter the file you want to open: ")</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">params = open(filename, 'r')</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">for i in params:</FONT>

<BR>        <FONT SIZE=2 FACE="Arial">print 'IPB = ' ,i</FONT>

<BR><FONT SIZE=2 FACE="Arial"># end code</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">This obviously results in the following:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">IPB =  x11      .32</FONT>

<BR><FONT SIZE=2 FACE="Arial">IPB =  x22      .45</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">So, my questions may be trivial, but:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">1) How do I print the 'IPB = ' before the numbers? </FONT>

<BR><FONT SIZE=2 FACE="Arial">2) Is there a better way to prompt the user to open the desired file rather than the way I have it above? For example, is there a built-in function that would open a windows dialogue box such that a user who does not know about path names can use windows to look for the file and click on it. </FONT></P>

<P><FONT SIZE=2 FACE="Arial">3) Last, what is the best way to have the output saved as a new file called 'test2.txt'. The only way I know how to do this now is to do something like:</FONT></P>

<P><FONT SIZE=2 FACE="Arial">python test.py > test2.txt</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Thank you for any help</FONT>
</P>

</BODY>
</HTML>