'''
Track no of resources requested with each attribute
'''

attList = ['resptime', 'oneminload', 'freemem', 'disk_free', 'gb_free', 'freecpu', 'txrate', 'location', 'cpuspeed', 'memsize', 'uptime', 'fiveminload']
fdIn = open('NumResAttCorr.txt', 'r')
fdOut = open('NumResAttCorr_count.txt', 'w')

count = {}
for line in fdIn:
    for i in attList:
        if i in line:
            numRes = int(line.split('\t')[0])
            if i in count: count[i].append(numRes)
            else: count[i] = [numRes]
fdIn.close()

for i in count:
    numTimes = {} #Number of times that a particular value appear
    for j in count[i]:
       if j in numTimes: numTimes[j] += 1
       else: numTimes[j] = 1
    fdOut.write(i + '\n') 
    for k in numTimes:
        fdOut.write(str(k) + '\t' + str(numTimes[k]) + '\n')
fdOut.close()
