My loop script is iterating too many times. The first return result is fine, but the second is the total of the 1st and 2nd, then the 3rd is the total of the 2nd and 3rd, and so on.
What I expect to get:
15 152
67 101
7 161
7 161
13 155
13 155
What I’m getting:
15 152
82 253
89 414
96 575
109 730
122 885
Script:
‘’’
rawDS = data[“named_query”].getCoreResults()
machines = []
tags = system.tag.browseTags(parentPath="[default]CoorsTek/Benton/Furnaces", tagType = “UDT_INST”)
for tag in tags:
machines.append(tag.name)
machinesSorted = sorted(machines)
headers = [‘Equipment’,‘Uptime’,‘Downtime’]
upList = []
downlist = []
upTimeList = []
downTimeList = []
for x in machinesSorted:
for row in range(rawDS.getRowCount()):
if rawDS.getValueAt(row,x) == 1:
upList.append(rawDS.getValueAt(row,x))
if rawDS.getValueAt(row,x) == 3:
downlist.append(rawDS.getValueAt(row,x))
downHours = len(downlist)/60
upHours = len(upList)/60
upTimeList.append(upHours)
downTimeList.append(downHours)
dsList = zip(machinesSorted,upTimeList,downTimeList)
filteredDS = system.dataset.toDataSet(headers,dsList)
data["Report Basic Data"] = filteredDS
‘’’
The items in the “machinesSorted” list match the names of columns in “rawDS”. Each row in rawDS is a machine status integer every minute.
Can anyone see where I went astray with my for statements? Any help would be much appreciated.