'''
Format sensor readings such that it can be fed to simulator
Skip -1 values
'''

#Format NID Time, [x, value]	[y, value], [ELEV, value], [Att1, value], ...

fdIn = open('subsetSensors_corrected.txt', 'r')
fdOut = open('SReadings.txt', 'w')

for line in fdIn:
    l = line[:-1].split()
    tmpStr = l[0] + '\t' + l[1]
    assert(l[2] != '-1' and l[3] != '-1' and l[4] != '-1'), 'X, Y, ELEV missing'
    tmpStr += '\tX\t' + l[2] + '\tY\t' + l[3] + '\tELEV\t' + l[4]
    if l[5] != '-1': tmpStr += '\tRH\t' + l[5]
    if l[6] != '-1': tmpStr += '\tP\t' + l[6]
    if l[7] != '-1': tmpStr += '\tT\t' + l[7]
    if l[8] != '-1': tmpStr += '\tDD\t' + l[8]
    if l[9] != '-1': tmpStr += '\tFF\t' + l[9]
    fdOut.write(tmpStr + '\n')

fdIn.close()
fdOut.close()
