dataIn = [
{"t_stamp":1636027386514,"MachineStatus":"Own Fault"},
{"t_stamp":1636027447697,"MachineStatus":"Downstream Fault"},
{"t_stamp":1636027450786,"MachineStatus":"UpStream"},
{"t_stamp":1636027494988,"MachineStatus":"Idle"},
{"t_stamp":1636027496031,"MachineStatus":"Own Fault"},
{"t_stamp":1636027497048,"MachineStatus":"Production Mode"}
]
dataOut = []
for row, nextRow in zip(dataIn, dataIn[1:]):
dataOut.append(
{
'fromDate': row['t_stamp'],
'toDate' : nextRow['t_stamp'],
'MachineStatus' : row['MachineStatus']
}
)
dataOut.append(
{
'fromDate': nextRow['t_stamp'],
'toDate' : nextRow['t_stamp'],
'MachineStatus' : nextRow['MachineStatus']
}
)
3 Likes