'''
Created on June 5, 2012
Modified on June 26, 2012
@author: Dilum Bandara
@version: 0.1
@license: Apache License v2.0

   Copyright 2012 H. M. N. Dilum Bandara and Anura P. Jayasumana, Colorado State
   University

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
'''

'''
Extract time series of given machine
'''

import sys

nID = int(sys.argv[1])
startTime = 1335139200 
#startTime = 1335139200 + 86400 * 4
endTime = startTime + 86400 * 3

fdIn = open('multipleAttributes.txt', 'r')
fdOut = open('node' + sys.argv[1] + '.txt', 'w')
firstLine = True

for line in fdIn:
    if firstLine == True:
        fdOut.write(line)
        firstLine = False
        continue
    tmp = line.split('\t')
    if int(float(tmp[1])) > endTime: break
    if int(float(tmp[1])) < startTime: continue
    if int(tmp[0]) == nID:
        fdOut.write(line)
fdIn.close()
fdOut.close()
