I think I did well.
Dunning Krueger says I wouldn't know it if I didn't do well.
Last year, someone said my code only worked because of a bug and helped me haha.
So I hope that is not the case now.
I wanted a really small footprint so I avoided defining functions.
propsValues is a list of 6 rows of strings.
#Process Tags
cells = [['Cell{}'.format(i)] for i in xrange(1,7)]
todays = [[str(system.date.format(system.date.now(),'yyyy/MM/dd'))] for i in xrange(1,7)]
testStarts = [[str(system.date.format(tagValues[0].value,'HH:mm:ss'))] for i in xrange(1,7)]
testEnds = [[str(system.date.format(i.value,'HH:mm:ss'))] for i in tagValues[1:7]]
seconds = [[system.date.secondsBetween(i, j)] for [i,j] in zip((tagValues[0].value for i in xrange(1,7)),(i.value for i in tagValues[1:7]))]
durations = [['{:02d}:{:02d}:{:02d}'.format(i*1//3600,i//60%60,i%60)] for [i] in seconds]
dW = [[round(i.value,2)] for i in tagValues[7:13]]
wW = [[round(i.value,2)] for i in tagValues[13:19]]
zW = [[round(j-i,2)] for [i,j] in zip((i for [i] in dryWeights), (i for [i] in wW))]
ratio = [[round((i/j) if i>0 and j>0 else 0,2)] for (i,j) in zip((i for [i] in zW),(i for [i] in dW))]
rate = [[round((i/j) if i>0 and j>0 else 0,2)] for (i,j) in zip((i for [i] in zW),(i for [i] in seconds))]
enables = [[i.value] for i in tagValues[19:25]]
enables = [j for i in enables for j in i]
#Process OPCs
sampleValues = [[[i, round(qv.value,2)] for i, qv in enumerate(opcValues[240*p:240*p+ 240],start=1)] for p in xrange(6)]
sampleValues = [[float(j) for i,j in m]for m in sampleValues]
sampleHeaders = ['Sample '+str(i) for i,j in enumerate(sampleValues[0])]
#Create Dataset
data = []
data = list(zip(cells, todays, testStarts, testEnds, durations, propValues, dW, wW,zW, ratio, rate, sampleValues))
data = [list(i) for i in data ]
data = [[j for i in data[p] for j in i ] for p in xrange(6)]
metaHeaders = ['Cell', 'Day', 'Start', 'End', 'Duration',
'Text1', 'Text2', 'Text3', 'Text4', 'Text5', 'Text6', 'Text7',
'dW', 'wW', 'zW', 'dW/zW', 'zW/Second']
headers = metaHeaders+sampleHeaders
#Filter Data
data = [j for i,j in zip(enables,data) if i==True]
dataOut = system.dataset.toDataSet(headers, data)
print len(headers), len(data[0])
print 'headers', headers
for row in data:
print 'filtered data', row
#Export Dataset
today = system.date.now()
fileSuffix = system.date.format(today, "yyyyMMddHHmm")
fileName = 'Results' +fileSuffix+'.xlsx'
ss = system.dataset.toExcel(True, [dataOut], sheetNames = ['Results'])
#end=time.clock()
#print end-start
filePath = system.file.saveFile(fileName)
if filePath is not None:
system.file.writeFile(filePath, ss)