我想将CSV文件中的数据发布到InfluxDB文件,InfluxDB的Time列应该与CSV文件Time列匹配。我的意思是InfluxDB时间序列应该与CSV文件的时间序列相同。
我的主要动机是InfluxDB应该以CSV文件的时间序列存储CSV文件的数据。
CSV文件如下所示
Time Energy Power
12-26-2017 7:34:27 103691 24.838
12-26-2017 7:35:28 103693 19.525
我已使用此spice代码将CSV文件的时间转换为epoch以发送InfluxDB服务器
t = "2017-12-26 07:34:27"
lctime = (int(time.mktime(time.strptime(t,"%Y-%m-%d %H:%M:%S")))) * 1000000000 #in nano second`
我已将此数据以JSON格式发布到InfluxDB服务器。
client.write_points([
{"measurement": "Meter1",
"tags":{"host": "localPC",
"Region": "Northam"},
"Time":lctime,
"fields":{"Energy": e1,
"Power": p1,
}
}
]
将这些数据发布到InfluxDB服务器没有问题但我在数据库面板中使用此查询检查是否已将正确的数据写入Influxdb。
Select * From Meter1
潮流数据库向我展示了这个" 2018-01-04T05:43:41.580065574Z"时间,但它应该向我展示" 2017-12-26 07:34:27"与CSV文件的时间相同。
请告诉我哪种方法可以匹配CSV和InfluxDB的时间?
请告诉我哪种方法可以做我想要的东西?