How to ignore timezone in csv data

自作多情 提交于 2020-01-16 00:49:12

问题


I have some csv data I'm trying to plot in gnuplot.

example:

1,2014-11-07T16:00:03+13:00
2,2014-11-07T15:55:03+13:00
3,2014-11-07T15:50:04+13:00
4,2014-11-07T15:45:03+13:00
5,2014-11-07T15:40:03+13:00
6,2014-11-07T15:35:03+13:00

This won't work

set timefmt "%Y-%m-%dT%H:%M:%SZ"

These are New Zealand dates which will change between +12:00 and +13:00

I realise that gnuplot doesn't play nice with timezones. I don't have the option to remove the zone at the source, so how do I set it to just ignore the +13:00 so it's just working in my local time?


回答1:


You can use gnuplot's string functions to remove the time zone part from the data. In this case you don't need to use set timefmt, but the time values are parsed inside the using statement with strptime.

set datafile separator ','
set xdata time

fmt = "%Y-%m-%dT%H:%M:%S"
timeval(s) = strptime(fmt, substr(s, 0, strstrt(s, '+')-1))

plot 'data.csv' using 1:(timeval(strcol(2)))


来源:https://stackoverflow.com/questions/26793373/how-to-ignore-timezone-in-csv-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!