chris
chris

Reputation: 131

gnuplot timefmt error from csv input "Bad time format"

I'm trying to plot a 500 MB csv file of two columns as below:

ID,"timestamp"
1,"2016-02-09 14:46:52.683"
2,"2016-02-09 14:47:02.687"
3,"2016-02-09 14:47:09.896"
4,"2016-02-09 14:47:12.702"
5,"2016-02-09 14:47:22.663"
6,"2016-02-09 14:47:32.668"
7,"2016-02-09 14:47:42.68"
8,"2016-02-09 14:47:52.676"
9,"2016-02-09 14:48:02.661"

I've written a gnuplot script but am unsure where I'm going wrong. I've followed other posts too. What am I missing?

I think that the milliseconds data sometimes has few values could be an issue - but again, I'm not sure how to resolve.

Many thanks in advance! Chris

set datafile separator ","
set key autotitle columnhead
set xdata time
set timefmt '"%Y-%m-%d %H:%M:%.6S"'
set format x "%Y-%m-%d %H:%M:%.6S"
# set xrange ['"2016-04-01 00:00:00.000000"':'"2016-05-01 17:00:00.000000"']
plot "~/timestampi.csv" u 2:1

Output:

Terminal type set to 'qt'
gnuplot> load "~/g.p"
         "/home/chrisb/g.p", line 6: warning: Bad time format in string
         "/home/chrisb/g.p", line 6: warning: Bad time format in string
         "/home/chrisb/g.p", line 7: warning: Skipping data file with no valid points

gnuplot> plot "~/timestampi.csv" u 2:1 w l
                                          ^
         "/home/chrisb/g.p", line 7: all points y value undefined!

gnuplot> 

Upvotes: 3

Views: 1312

Answers (1)

Christoph
Christoph

Reputation: 48430

Specifying an explicit second precision is supported only for the tic labels. When parsing the input data, seconds are always parsed as floats:

set datafile separator ","
set key autotitle columnhead
set xdata time
set timefmt '"%Y-%m-%d %H:%M:%S"'
set format x "%Y-%m-%d %H:%M:%.6S"
set xrange ['"2016-04-01 00:00:00"':'"2016-05-01 17:00:00"']
plot "~/timestampi.csv" u 2:1

Note, that using %.6S with set format works, but doesn't make sense, since with such large time ranges you won't get tics at fractionals of a second.

Upvotes: 1

Related Questions