Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot: Use only last n line

Tags:

csv

gnuplot

I'm using a python script to record data from two temperature sensors to a .csv file. For every reading (every 5 mins) a new line is added to the end of the file. How can I get gnuplot to only use the last 288 lines, so I will end up with a graph for the last 24 hrs?

Thanks!

:Edit:

Got it, thanks for the hint @Istvan Chung.

A simple

plot '< tail -n 288 datafile.csv' using ...

seems to do the trick.

like image 278
fidepus Avatar asked May 10 '14 22:05

fidepus


1 Answers

An easy solution here is to use the unix tail command to select the last 288 lines.

I suggested in a comment that

tail -n 288 <file> | gnuplot -p -e "set datafile separator \",\"; plot '-'"

should work. According to an edit on the original question, the correct syntax here was of the form

plot '< tail -n 288 datafile.csv' using ...
like image 116
Lily Chung Avatar answered Sep 28 '22 07:09

Lily Chung