如何忽略CSV数据中的时区 [英] How to ignore timezone in csv data

查看:116
本文介绍了如何忽略CSV数据中的时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些要在gnuplot中绘制的csv数据.

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

示例:

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

这行不通

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

这些是新西兰的日期,将在+12:00和+13:00之间更改

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

我意识到gnuplot在时区中的表现不佳.我没有从源头删除区域的选项,那么如何将其设置为仅忽略+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?

推荐答案

您可以使用gnuplot的字符串函数从数据中删除时区部分.在这种情况下,您不需要使用set timefmt,但是可以使用strptimeusing语句中解析时间值.

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)))

这篇关于如何忽略CSV数据中的时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆