By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,660 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,660 IT Pros & Developers. It's quick & easy.

reading from a txt file

P: n/a
how should i modify this data reader:
(assumes that there is only one entry per line followed by '\n')

data_file = open(os.path.normpath(self.TextFile.GetValue()), 'r')
data = data_file.readlines()

self.irradianceStrings = map(str, data)
self.irradianceIntegers = map(int, data)
self.IrradianceExecute.SetValue(''.join(self.irrad ianceStrings))

so that i can read the text file created by this:

self.filename = "%s\%s.txt"
%(os.path.normpath(self.SaveFolder.GetValue()),tim e.strftime("%Y%m%d%H%M"))

self.table_file = open(self.filename,"a")
self.table_file.write('%f\t'%self.temp11)
self.table_file.write('%f\t'%self.temp22)
self.table_file.write('%f\t'%self.pyra11)
self.table_file.write('%f\t'%self.pyra22)
self.table_file.write('%f\t'%self.voltage11)
self.table_file.write('%f\t'%self.current11)
self.table_file.write('\n')
self.table_file.close()
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
you should have that file i/o in some try: except: pairs for starters.
and you should close data_file when you are done. isn't it just
data_file.read() ?

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.