import collections def parse_array(): with open("log_16-aa") as log_file: # rearrange data lines_parsed = [] lines = log_file.readlines() for line in lines: if "iv[0]" in line: line_splitted = line.split()[2::3] lines_parsed.append(line_splitted) # create histogram histogram = {} for i in range(len(lines_parsed)): for j in range(len(lines_parsed[i])): histogram[j] = histogram.get(j, []) histogram[j].append(lines_parsed[i][j]) # iterate histogram for position, values in histogram.items(): print(collections.Counter(values)) parse_array()