Plot data from file while is file is constantly updated

Hi,

I have a textfile where every second a line is written. Usually the look like this:

1; 124; 455

a second later

1; 124; 455
2; 104; 600

Finally
such a file is quite easy to plot using matplotlib. But what would be very useful for me is a script, that is watching the TXT file and updates the
plot when a new row “arrives”. Any good ideas?

Cheers,

Sebi

Hi,

what about opening-closing the file every now and then, for example every 5seconds?

you can do it using the function time(). It gives you the amount of time since I don’t kno when,

but you can count how many seconds are left using:

a=time()

while 1:

b=time()

left= b-a

if left == 5sec:

updating plot

Actually is very cpu consuming, but it is the best I can propose :frowning:

Francesco

···

2012/11/8 Sebastian Rhode <sebrhode@…287…>

Hi,

I have a textfile where every second a line is written. Usually the look like this:

1; 124; 455

a second later

1; 124; 455
2; 104; 600

Finally
such a file is quite easy to plot using matplotlib. But what would be very useful for me is a script, that is watching the TXT file and updates the
plot when a new row “arrives”. Any good ideas?

Cheers,

Sebi


Everyone hates slow websites. So do we.

Make your web apps faster with AppDynamics

Download AppDynamics Lite for free today:

http://p.sf.net/sfu/appdyn_d2d_nov


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Cordiali saluti, Dr.Oteri Francesco

Hi,

You could use the time module.

import time

while 1:

time.sleep(5) # freezes for 5 s

update plot

This should be less CPU consuming …

lpmp

···

2012/11/8 Sebastian Rhode <sebrhode@…287…>

Hi,

I have a textfile where every second a line is written. Usually the look like this:

1; 124; 455

a second later

1; 124; 455
2; 104; 600

Finally
such a file is quite easy to plot using matplotlib. But what would be very useful for me is a script, that is watching the TXT file and updates the
plot when a new row “arrives”. Any good ideas?

Cheers,

Sebi


Everyone hates slow websites. So do we.

Make your web apps faster with AppDynamics

Download AppDynamics Lite for free today:

http://p.sf.net/sfu/appdyn_d2d_nov


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Cordiali saluti, Dr.Oteri Francesco

If you are in a Linux machine, you can use `inotify`: "Inotify (inode
notify) is a Linux kernel subsystem that acts to extend filesystems to
notice changes to the filesystem".

It seems that there are a few option to use this from Python:

http://pyinotify.sourceforge.net/
http://code.activestate.com/recipes/576375-low-level-inotify-wrapper/

Alejandro.

···

On Thu, Nov 8, 2012 at 1:34 AM, Sebastian Rhode <sebrhode@...287...> wrote:

Hi,

I have a textfile where every second a line is written. Usually the look
like this:

1; 124; 455

a second later

1; 124; 455
2; 104; 600

...

Finally such a file is quite easy to plot using matplotlib. But what would
be very useful for me is a script, that is watching the TXT file and updates
the plot when a new row "arrives". Any good ideas?

Cheers,

Sebi

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

In bash:

watch -n1 tail file.txt

···

On Thursday, November 8, 2012, Alejandro Weinstein wrote:

If you are in a Linux machine, you can use inotify: "Inotify (inode

notify) is a Linux kernel subsystem that acts to extend filesystems to

notice changes to the filesystem".

It seems that there are a few option to use this from Python:

http://pyinotify.sourceforge.net/

http://code.activestate.com/recipes/576375-low-level-inotify-wrapper/

Alejandro.

On Thu, Nov 8, 2012 at 1:34 AM, Sebastian Rhode <sebrhode@…287…> wrote:

Hi,

I have a textfile where every second a line is written. Usually the look

like this:

1; 124; 455

a second later

1; 124; 455

2; 104; 600

Finally such a file is quite easy to plot using matplotlib. But what would

be very useful for me is a script, that is watching the TXT file and updates

the plot when a new row “arrives”. Any good ideas?

Cheers,

Sebi


Everyone hates slow websites. So do we.

Make your web apps faster with AppDynamics

Download AppDynamics Lite for free today:

http://p.sf.net/sfu/appdyn_d2d_nov


Matplotlib-users mailing list

Matplotlib-users@…1739…ge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Everyone hates slow websites. So do we.

Make your web apps faster with AppDynamics

Download AppDynamics Lite for free today:

http://p.sf.net/sfu/appdyn_d2d_nov


Matplotlib-users mailing list

Matplotlib-users@…1064…t

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Damon McDougall
http://www.damon-is-a-geek.com

B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom