if finished == True: break path = os.path.join(basepath, files) if os.path.isdir(path): for logFile in os.listdir(path): if limit == 0: finished = True break with open(os.path.join(path,logFile), 'r') as h: lines = h.readlines() for line in lines: if line: feature = [features.durationLessThanMinute(line)] feature.extend([features.durationOneToFive(line)]) feature.extend([features.durationFiveOrMore(line)]) feature.extend([features.device(line)]) feature.extend(features.ipFeature(line)) feature.extend(features.timeStartFeature(line)) feature.extend(features.timeEndFeature(line)) arrayOfFeatures.append(feature) limit -= 1 print "limit: ", limit nparray = np.array(arrayOfFeatures) print nparray.shape row, col = nparray.shape
def feature3(self): if features.durationFiveOrMore(self.line): return 1 else: return 0