Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102546

realtime output and csv files

From lucan <lucan@NNN.it>
Newsgroups comp.lang.python
Subject realtime output and csv files
Date 2016-02-05 20:49 +0100
Organization Aioe.org NNTP Server
Message-ID <n92ucb$1h5s$1@gioia.aioe.org> (permalink)

Show all headers | View raw


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 = datetime.datetime.now()
dayexperiment = str(now.day)+str(now.month)+str(now.year)

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

index = 0
count = 1

timestep = 10


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

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

	now = datetime.datetime.now()
	file.write('\n'+str(index))
	
f.write(str(index)+','+str(now.hour)+':'+str(now.minute)+', '+str(temp))
		
		index +=1
		time.sleep(timestep)




Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

realtime output and csv files lucan <lucan@NNN.it> - 2016-02-05 20:49 +0100
  Re: realtime output and csv files Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 17:57 -0200
    Re: realtime output and csv files lucan <lucan@NNN.it> - 2016-02-05 22:09 +0100
      Re: realtime output and csv files Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:13 -0200
      Re: realtime output and csv files Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-05 16:43 -0500
      Re: realtime output and csv files Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-05 19:51 -0200
        Re: realtime output and csv files lucan <lucan@NNN.it> - 2016-02-06 14:40 +0100
      Re: realtime output and csv files Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-05 17:12 -0500
  Re: realtime output and csv files Tim Chase <python.list@tim.thechases.com> - 2016-02-05 22:27 -0600
  Re: realtime output and csv files Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-02-06 02:53 -0200
  Re: realtime output and csv files Tim Chase <python.list@tim.thechases.com> - 2016-02-06 06:45 -0600

csiph-web