Write Data to an Arbitrary Tag

About this task

You can write data to an arbitrary tag in the Historian archive through the Historian.AddData function. This function is used in a python script to write values, time stamps and qualities of one or more tags to the Historian archive.

Use the following syntax ri write data to an arbitrary tag:

Historian.AddData(TagNames, Values, Timestamps, Qualities)

The following table provides information on the parameters.

Parameter Description
TagNames Identifies the names of the tags. A value is required, and must exist in the archive to which you want to send the tag data. You can provide a single tag name or an array of tag names, enclosed in double quotation marks.
Values Identifies the values of the tags. A value is required, and must be a single value or an array of values, depending on whether the tag name is a single name or an array. Values must be enclosed in double quotation marks. You can enter only a single value for each tag name.
TimeStamps Identifies the timestamp of the tag data. Enter an absolute time value, enclosed in double quotation marks. All times are provided as string in standard ISO 8601 format.
Qualities Identifies the quality of the tag data. Enter an integer from 0 to 100, with 0 indicating bad quality and 100 indicating good quality.

Example of using AddData Function


from datetime import datetime	
tags = ["TestTag1", "TestTag2", "TestTag3"]
values = ["111", "222", "333"]
datetime_str = Historian.CurrentTime()
datetime_object = datetime.strptime(datetime_str, '%m/%d/%y %H:%M:%S.%f')
times = [datetime_object.isoformat(),datetime_object.isoformat(), datetime_object.isoformat()]
Historian.AddData(tags, values,times, "")
Result=1