#Extract subset of attributes from file with 24 attributes. This is a hack as original data files were lost
#If need  original file can be generated following all necessary steps
#Last updated June 07

fIn = 'resources_3_24_1.txt'
fOut = 'resources_3_21_1.txt'
fdIn = open(fIn, 'r')
fdOut = open(fOut, 'w')

att_to_extract = ['nid', 'time', 'Loc', 'Lati', 'Longi', 'NType', 'KVer', 'FCName', 'CSp', \
                'NCore', 'CorePC', 'MSize', 'DSize', 'BWLim', 'RspT', '1mLd', 'CFree',\
                'DFree', 'MFree', 'Tx', '5mLd', 'UpT', 'Drift']
              #'TAve', 'Boot', 'Rx']
first_line = False
idx = []

for line in fdIn:
    tmp = line.split()
    if first_line == False:
        for i in range(len(tmp)):
            if tmp[i] in att_to_extract: 
                idx.append(i)
    tmp_str = tmp[0]
    for i in range(1, len(idx)):
        tmp_str += '\t' + tmp[idx[i]]
    tmp_str += '\n'
    fdOut.write(tmp_str)
fdIn.close()
fdOut.close()        
