Hi everyone,
I am trying to make a dynamic table that will update on a set time. It will show the current downtime time, current downtime occurrences, and previous downtime occurrences of the previous shift. It will sort it all by occurrences. All this info comes from the cells PLC. I am having a problem I can’t seem to get around I keep getting an error on the sorting of the below code. The error is Row 0 doesn’t have the same number of columns as header list. Below the code is a copy of the first few lines from the exception at the top you can see what the print data returns. Please help.
Edit: FYI, I am really new to this scripting. This is the first real scripting I have done in Ignition.
def DT(line):
from operator import itemgetter
pathList = []
data = []
pathList = ('[Mexico]Die Cast/'+line+'/Cell Misc/Fault Occurrences/Fault_Occur/fCell/Name','[Mexico]Die Cast/'+line+'/Cell Misc/Fault Occurrences/Fault_Occur/fCell/Current_Count','[Mexico]Die Cast/'+line+'/Cell Misc/Fault Occurrences/Fault_Occur/fCell/Current_Time','[Mexico]Die Cast/'+line+'/Cell Misc/Fault Occurrences/Fault_Occur/fCell/Prev_Count')
headers = ['Equip', 'Current_Count', 'Current_Time', 'Prev Shift Count']
data = [[tagName.split('/')[-1], qualified.value] for tagName, qualified in zip(pathList, system.tag.readAll(pathList))]
print data
dataset = system.dataset.toDataSet(headers, sorted(data, key=itemgetter(1), reverse=True))
[[u'Name', u'Cell'], [u'Current_Count', 2], [u'Current_Time', 68], [u'Prev_Count', 0]]
05:48:11.364 [AWT-EventQueue-0] ERROR com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter - <HTML>Error executing script for event: <code><b>actionPerformed</b></code><BR>on component: <code><b>Button</b></code>.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
File "<event:actionPerformed>", line 1, in <module>
File "<module:project.Top3DT>", line 15, in DT
IndexError: Row 0 doesn't have the same number of columns as header list.