I am trying to read in data from a file that I have created. The file
exists, and the following code allows me to select the file for reading.
However when I try to access the data, nothing happens. Here is the code
to run the wxFileDialog and select and open the file.
#Go ahead and open the data file now so that we don't have
timing problems later.
#Pop up a dialog to name the data file that we'll take our
input from
self.datafilesel = wxFileDialog(self, message="Choose a data
file.",
defaultDir = "C:/",wildcard = "*.dat", )
#Display the File Dialog
self.datafilesel.ShowModal()
#Kill the File Dialog after obtaining input
self.datafilesel.Destroy()
datafile = self.datafilesel.GetFilename()
#Open data file with selected name for reading
data_file = open('C:/'+datafile, 'r+')
It seems to work to this point, but after a little more code is
executed, I try this:
if: <snip>
else: #Transmit data from input file.
print "Got here.\n"
for line in data_file.readlines():
print "Got here too.\n"
print line
I get the first "Got here." but not the "Got here too." Does anyone see
what I am doing wrong here?
--vicki