fName = 'queries_950000_24_2'
fdIn = open(fName + '.txt', 'r')
fdOut = open(fName + '_thres.txt', 'w')

for line in fdIn:
    newData = []
    tmp = line.split()
    tmpStr = tmp[0] + '\t' + tmp[1] + '\t'
    numAtts = (len(tmp) - 2)/3
    for j in range(numAtts):
        i = 2 + j * 3
        newData.append(tmp[i])
        if tmp[i] == 'Loc': 
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        elif tmp[i] == 'Lati' or tmp[i] == 'Longi':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'NType' or tmp[i] == 'KVer' or tmp[i] == 'FCName': 
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        elif tmp[i] == 'CSp':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'NCore' or tmp[i] == 'CorePC':
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        elif tmp[i] == 'MSize':
            newData.append(round(float(tmp[i + 1]), 2))
            newData.append(round(float(tmp[i + 2]), 2))
        elif tmp[i] == 'DSize':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'BWLim' or tmp[i] == 'CFree':
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        elif tmp[i] == 'DFree':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'Tx' or tmp[i] == 'Rx' or tmp[i] == 'MFree':
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        elif tmp[i] == 'RspT':
            newData.append(round(float(tmp[i + 1]), 2))
            newData.append(round(float(tmp[i + 2]), 2))
        elif tmp[i] == 'UpT' or tmp[i] == '1mLd' or tmp[i] == '5mLd':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'TAve':
            newData.append(round(float(tmp[i + 1]), 1))
            newData.append(round(float(tmp[i + 2]), 1))
        elif tmp[i] == 'Drift':
            newData.append(round(float(tmp[i + 1]), 2))
            newData.append(round(float(tmp[i + 2]), 2))
        elif tmp[i] == 'Boot':
            newData.append(int(round(float(tmp[i + 1]), 0)))
            newData.append(int(round(float(tmp[i + 2]), 0)))
        else: assert(False), tmp[i]
    for i in newData: tmpStr += str(i) + '\t'
    fdOut.write(tmpStr + '\n')

fdIn.close()
fdOut.close()
