InfluxDB v2 在 R 中注释了 csv

InfluxDB v2 annotated csv in R

InfluxDB 和 Flux return 以带注释的 CSV 格式查询结果。我正在使用 InfluxDB v2 API 从 R studio 查询数据。如何处理我收到的带注释的 csv 格式的数据?

带注释的 csv:

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:14:48.74Z,1,MONITORING,MONITORING,L4212M1017,1
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:23.238Z,0,MONITORING,MONITORING,L4212M1017,1
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:39.918Z,1,MONITORING,MONITORING,L4212M1017,1

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,1,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:44.53Z,0,MONITORING,MONITORING,L4212M1017,2

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,2,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:17:57.538Z,0,MONITORING,MONITORING,L4212M1017,3
,,2,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:17.006Z,1,MONITORING,MONITORING,L4212M1017,3

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:14:48.74Z,1,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:17:57.538Z,0,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:17.007Z,1,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:23.239Z,0,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:39.919Z,1,MONITORING,MONITORING,L4212M1017,4

有人有使用 Influx 和 R 的经验吗?

您可以尝试使用 InfluxDB 2.0 R client:

library(influxdbclient)

client <- InfluxDBClient$new(
    url = "http://localhost:8086",
    token = "my-token",
    org = "my-org")
                    
data <- client$query('from(bucket: "my-bucket") |> range(start: -1h)')