I am passing a list of Tags, start date and end date to the “queryTagHistory” function.
tagList = ['[default]RECEITA/BRel/BRel_0_/BatchId.value',
'[default]RECEITA/BRel/BRel_0_/NumFicha.value']
startTime = request['params']['inicio']
endTime = request['params']['fim']
tags = system.tag.queryTagHistory(paths=tagList, startDate=startTime, endDate=endTime, returnSize=3, aggregationMode="LastValue", returnFormat='Wide')
return {'json': system.util.jsonEncode(tags)}
see the result below:
How can I implement a for to loop through this list and return the data as follows:
{
"result3": [
{
"value2": 0,
"value1": "Jun 23, 2022, 7:25:05 AM",
"value3": 0
}
],
"result2": [
{
"value2": 0,
"value1": "Jun 19, 2022, 7:21:49 AM",
"value3": 0
}
],
"result1": [
{
"value2": 0,
"value1": "Jun 15, 2022, 7:18:33 AM",
"value3": 0
}
]
}
I’m trying something like:
headers = ['result1', 'result2', 'result3']
data =[]
for tag in tags:
data.append([tag.value])
ds = system.dataset.toDataSet(headers,data)
convertData = system.dataset.toPyDataSet(ds)
If anyone can help me