[Tutor] Problems writing data into a file

Stefan Heyne stefan.heyne at epfl.ch
Mon Dec 18 09:00:52 CET 2006


Hi there,

I am newby to python and have some problems getting data into a file....
I am using python to extract data from a database but currently i only 
get it to print the data on the screen so I have to copy/paste it into a 
file later on.
There for sure is a way to do that but I couldn't figure out how 
to....the commented lines show my trials that did not really work :-P......
Any help appreciated....thanks in advance!

Stefan

for x in range(1,226):
#   g=open('output', 'w')
     y1=m.extract('TEMP',32, 1131, component='1', cycle=x, subcycle=1)
     y2=m.extract('PRES',32, 1131, component='1', cycle=x, subcycle=1)
#   testout = (x,y1,y2,'\n')
#   line = str(testout)
#   g.write(line)
     print x,y1,y2
#   g.close()

-- 
************************************************
Stefan Heyne
Laboratoire d'Energétique Industrielle - http://leni.epfl.ch

tél. +41-21-693 3513
fax +41-21-693 3502
email: stefan.heyne at epfl.ch
Bureau: ME A2.394 - http://plan.epfl.ch/index.html?room=mea2394 

Adresse postale:
EPFL, STI-ISE-LENI
ME A2.394 (Bâtiment ME)
Station 9
CH-1015 Lausanne
************************************************



More information about the Tutor mailing list