[Tutor] New to Python
jeremy.traurig at gmail.com
Fri May 18 08:45:51 CEST 2012
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:
#! /usr/bin/env python
# Read NRG Text File
import numpy as np
f1 = open('SIL633_original.txt','r')
data = np.genfromtxt(f1,delimiter='\t',skip_header=141)
f2 = open('test.txt','w')
I'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 "def" statement in
the script and run again from the command line, a test.txt file is output.
I guess I'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.
thanks for any help -- jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor