def process_file(options): field_list = zd_lib.get_field_list() indexes = get_indexes(field_list, options.fields) current = [] equal = False prev_line = '' print '\t'.join(field_list) for log_line in sys.stdin: try: log_data = log_line.split('\t') if len(current) == 0: current = get_current(log_data, indexes) elif equal_values(log_data, indexes, current) == False: equal = False current = get_current(log_data, indexes) print prev_line, else: equal = True prev_line = log_line except IOError, e: if e.errno == errno.EPIPE: exit(0)
def process_file(options): field_list = zd_lib.get_field_list() indexes = [] for field in options.fields: indexes.append(field_list.index(field)) print_field_line(options.fields) for log_line in sys.stdin: try: log_line = log_line.rstrip() log_data = log_line.split('\t') print_line(log_data, indexes) except IOError, e: if e.errno == errno.EPIPE: exit(0)
def process_file(): global argv field_list = zd_lib.get_field_list() exec("include = lambda d: " + argv[1]) print '\t'.join(field_list) for log_line in sys.stdin: try: log_line = log_line.rstrip() log_data = log_line.split('\t') line = list_to_dict(log_data, field_list) if include(line): print log_line except IOError, e: if e.errno == errno.EPIPE: exit(0)
def process_file(options): field_list = zd_lib.get_field_list() print_field_line(field_list) # store the indexes of grouping fields grouped_by = [] for field in options.grouping: grouped_by.append(field_list.index(field)) data_field = field_list.index(options.data) current = [] # current field values of the current group data = [] # data the statistics will be computed over saved_lines = [] # log lines in the current group for log_line in sys.stdin: try: log_line = log_line.rstrip() log_data = log_line.split('\t') # first group if len(current) == 0: current = get_current(log_data, grouped_by) if in_group(log_data, grouped_by, current): data.append(log_data[data_field]) saved_lines.append(log_line) else: # end of group so calculate stats stats = calculate_stats(options, data) print_lines(saved_lines, stats) # store new group's values current = get_current(log_data, grouped_by) data = [] saved_lines = [] data.append(log_data[data_field]) saved_lines.append(log_line) except IOError, e: if e.errno == errno.EPIPE: exit(0)
def process_file(options): field_list = zd_lib.get_field_list() # store the indexes of combining fields indexes = [] for field in options.combine: indexes.append(field_list.index(field)) print_field_line(options.name, options.combine, field_list) for log_line in sys.stdin: try: log_line = log_line.rstrip() log_data = log_line.split('\t') print_combined(log_data, options.combine, field_list) print_other_fields(log_data, options.combine, field_list) except IOError, e: if e.errno == errno.EPIPE: exit(0)
def process_file(options): field_list = zd_lib.get_field_list() # store the indexes of the fields that will be added indexes = [] for field in options.add_fields: indexes.append(field_list.index(field)) print_field_line(options.name, field_list) for log_line in sys.stdin: try: log_line = log_line.rstrip() log_data = log_line.split('\t') print log_line + '\t', print_sum(log_data, options.add_fields, field_list) except IOError, e: if e.errno == errno.EPIPE: exit(0)