realtime output and csv files

lucan lucan at
Fri Feb 5 14:49:32 EST 2016

I'm new of python adn I'm using it only to complete some experiments.
I'm reading a series of data from various sensors and in the meantime 
I'm writing datas on a file. I would like to print output in realtime 
(or refresh it when I need) but the problem is that I'm writing on a 
file every x seconds (my timestep).
Anyway from the moment that datas are scientific value is it correct to 
write on a file using str(temp) and separating with ","?
I need a csv file to read it with some data analysis softwares.

now =
dayexperiment = str(

myfilename ="myData"+dayexperiment+".dat"

index = 0
count = 1

timestep = 10

with open(myfilename,'w') as f:
f.write('#Index Time Value')
while True:
	reading = ...

         print 'Temp{0:0.3F}*C'.format(temp)

	now =
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+', '+str(temp))
		index +=1

More information about the Python-list mailing list