generating stats from stdout on a regular interval

R

russ

Hi all,

Very new to Python - but excited to see what is possible - it sounds
very suitable for a project of mine I need a little help with.

I've got an executable which writes out data to stdout in a CSV sort
of format - I'd like to grab the data from stdout and create stats
from it at a regular interval, i.e. every 10 min. Probably push the
stats out to a CSV file.

The popen2 module can read the stdout just like a file, and the csv
module can handle the reading / writing. How do I go about
'processing' the stdout every 10 min?

Thanks,
Russ
 
G

Gabriel Genellina

Very new to Python - but excited to see what is possible - it sounds
very suitable for a project of mine I need a little help with.

I've got an executable which writes out data to stdout in a CSV sort
of format - I'd like to grab the data from stdout and create stats
from it at a regular interval, i.e. every 10 min. Probably push the
stats out to a CSV file.

The popen2 module can read the stdout just like a file, and the csv
module can handle the reading / writing. How do I go about
'processing' the stdout every 10 min?

The executable is continuously writting data to stdout, right?
So your code will likely be reading that output inside a loop - just check
using time.time() if the desired interval has elapsed.
Maybe you'd prefer using the subprocess module instead of popen2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top