Using the Script Console,
When I ran this code:
# Create a Python dictionary of parameters to pass.
params = {"fromDate":'2022-12-20 5:15:00', "toDate":'2022-12-20 13:15:00', "tool":"minical02"}
# Run the Named Query.
table = system.db.runNamedQuery("MiniCal_FaultCodes", params)
value = system.dataset.toPyDataSet(table) #Don't need this:
for row in value:
print row[0], row[1], row[2], row[3], row[4]
I get this :
0.0 1.0 0.0 1.0 1
1.0 0.0 2.0 0.0 2
0.0 10.0 2.0 0.0 3
0.0 0.0 1.0 6.0 4
5.0 4.0 5.0 1.0 5
0.0 0.0 0.0 2.0 7
I am missing the 6 in my row[4], Therefore, I would like to include this in my dataset:
0.0 0.0 0.0 0.0 6
So in the end, I end up having a complete set like this:
0.0 1.0 0.0 1.0 1
1.0 0.0 2.0 0.0 2
0.0 10.0 2.0 0.0 3
0.0 0.0 1.0 6.0 4
5.0 4.0 5.0 1.0 5
0.0 0.0 0.0 0.0 6
0.0 0.0 0.0 2.0 7
So far, this is what I've tried:
# Create a Python dictionary of parameters to pass.
params = {"fromDate":'2022-12-20 5:15:00', "toDate":'2022-12-20 13:15:00', "tool":"minical02"}
# Run the Named Query.
table = system.db.runNamedQuery("MiniCal_FaultCodes", params)
value = system.dataset.toPyDataSet(table) #Don't need this:
#for row in value:
# print row[0], row[1], row[2], row[3], row[4]
stationList = value.getColumnAsList(4)
print type(value)
x=0
newData = []
if len(value) == 7:
print [
{
value[row]["station"]
} for row in range (0, len(value))]
else:
# Finding missing elements in List
for row in range (0, 7):
x +=1
if x not in stationList:
value.append([0.0 0.0 0.0 0.0 x])
It's not taking the x as a variable ...