Hi Jeremy,<br><br>I am new to Python too. I find <a href="http://docs.python.org">docs.python.org</a> very helpful.<br><br><b>Understanding functions:</b><br><br><a href="http://docs.python.org/tutorial/controlflow.html#defining-functions">http://docs.python.org/tutorial/controlflow.html#defining-functions</a><br>
<br><b>Reading and Writing Files:</b><br><br><a href="http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files">http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files</a><br><br><b>File Objects:</b><br>
<br><a href="http://docs.python.org/library/stdtypes.html#file-objects">http://docs.python.org/library/stdtypes.html#file-objects</a><br><br><b>Comments - Coding Style</b><br><br><a href="http://www.python.org/dev/peps/pep-0008/#comments">http://www.python.org/dev/peps/pep-0008/#comments</a><br>
<br><br>Hope the above links are useful.<br><br>Thanks,<br>Vignesh<br><br><div class="gmail_quote">On Thu, May 17, 2012 at 11:45 PM, Jeremy Traurig <span dir="ltr">&lt;<a href="mailto:jeremy.traurig@gmail.com" target="_blank">jeremy.traurig@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<div><br></div><div>I very new to python and have been playing around with some simple code that I would eventually use in the real word. Below is the code I have created. I want the code to read data from a file called SIL633.txt and then output that data into another file called test.txt. below is my code:</div>

<div><br></div><div><div>#! /usr/bin/env python</div><div># Read NRG Text File</div><div>def readNRGtxt():</div><div><span style="white-space:pre-wrap">        </span>import numpy as np</div><div><span style="white-space:pre-wrap">        </span>f1 = open(&#39;SIL633_original.txt&#39;,&#39;r&#39;)</div>

<div><span style="white-space:pre-wrap">        </span>data = np.genfromtxt(f1,delimiter=&#39;\t&#39;,skip_header=141)</div><div><span style="white-space:pre-wrap">        </span>f1.close</div><div><span style="white-space:pre-wrap">        </span>f2 = open(&#39;test.txt&#39;,&#39;w&#39;)</div>

<div><span style="white-space:pre-wrap">        </span>np.savetxt(f2,data,fmt=&#39;%6.2f&#39;,delimiter=&#39;\t&#39;)</div><div><span style="white-space:pre-wrap">        </span>f2.close</div></div><div>
<br></div><div>I&#39;m running this on mac 10.5.8. When I run this script from the command line, there is no file output. However, if I remove the &quot;def&quot; statement in the script and run again from the command line, a test.txt file is output. I guess I&#39;m trying to understand why using the def statement changes how the script operates and since it does, how do I correct this code so it runs from the command line with the def statement.</div>

<div><br></div><div>thanks for any help -- jeremy</div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br>