如何从 CSV 文件中将数据插入 Influxdb

How to insert data into Influxdb from CSV file

我想将 CSV 文件中的数据插入 Influxdb。我试过下面的 Python 脚本。它成功了,但我希望它在特定时间插入(我有一列指定了日期)。

import pandas as pd
from influxdb import InfluxDBClient

client = InfluxDBClient(host='localhost', port=8086)
client.switch_database('databse_name')

file_path = r'file_name.csv'

csvReader = pd.read_csv(file_path)

print(csvReader.shape)
print(csvReader.columns)

for row_index, row in csvReader.iterrows() : 
    tags = row[1]
    #fieldvalue = row[2]
    json_body = [
        {
            "measurement": "Measurement_name",
            "tags": {
                        "Tag_name1": tags
                    },
            "fields": {
                        "Field1": row[2],
                        "Field2": row[3], 
                        "Field3": row[4]
                        }
        }
    ]
    client.write_points(json_body)

在 json_body 中指定 time:

json_body = [{
    "time": "<datetime, e.g. 2020-05-02T17:30:45Z>",
    "measurement": "Measurement_name",
    "tags": {
        "Tag_name1": tags
    },
    "fields": {
        "Field1": row[2],
        "Field2": row[3],
        "Field3": row[4]
    }
}]