Fixed the csv_to_influx : no attribute RecordInflux error and InfluxRequest needs time in utc format and not in string format

Signed-off-by: shivam <shivam.thakur@candelatech.com>
This commit is contained in:
shivam
2022-03-21 23:17:48 +05:30
parent 93cee54dfb
commit 08d7f3dd52
2 changed files with 4 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import sys
import os import os
import pandas as pd import pandas as pd
from influxdb_client import WritePrecision
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
print("This script requires Python 3") print("This script requires Python 3")
@@ -61,7 +62,7 @@ class RecordInflux():
for tag_key, tag_value in tags.items(): for tag_key, tag_value in tags.items():
p.tag(tag_key, tag_value) p.tag(tag_key, tag_value)
print(tag_key, tag_value) print(tag_key, tag_value)
p.time(time) p.time(datetime.datetime.strptime(time, '%Y-%m-%dT%H:%M:%S.%f').utcnow(), WritePrecision.NS)
p.field("value", value) p.field("value", value)
self.write_api.write(bucket=self.influx_bucket, org=self.influx_org, record=p) self.write_api.write(bucket=self.influx_bucket, org=self.influx_org, record=p)

View File

@@ -5,7 +5,6 @@ import importlib
from pathlib import Path from pathlib import Path
import argparse import argparse
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../"))) sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
cv_test_manager = importlib.import_module("py-json.cv_test_manager") cv_test_manager = importlib.import_module("py-json.cv_test_manager")
@@ -15,6 +14,7 @@ InfluxRequest = importlib.import_module("py-dashboard.InfluxRequest")
RecordInflux = InfluxRequest.RecordInflux RecordInflux = InfluxRequest.RecordInflux
influx_add_parser_args = InfluxRequest.influx_add_parser_args influx_add_parser_args = InfluxRequest.influx_add_parser_args
class CSVtoInflux: class CSVtoInflux:
def __init__(self, def __init__(self,
influx_host, influx_host,
@@ -34,7 +34,7 @@ class CSVtoInflux:
path = Path(self.path) path = Path(self.path)
self.kpi_list = list(path.glob('**/kpi.csv')) self.kpi_list = list(path.glob('**/kpi.csv'))
for kpi in self.kpi_list: for kpi in self.kpi_list:
self.influxdb.RecordInflux.csv_to_influx(kpi) self.influxdb.csv_to_influx(kpi)
def main(): def main():