import sys def process_file(input_file, noop_functions): data = {noop: [] for noop in noop_functions} with open(input_file, "r") as infile: for line in infile: for noop in noop_functions: if noop in line: value = line.split(",")[6] data[noop].append(value) for noop, values in data.items(): with open(f"{noop}.txt", "w") as outfile: outfile.write("\n".join(values)) if __name__ == "__main__": noop_functions = ["noop1", "noop2", "noop3", "noop4", "noop5"] argv = sys.argv[1:] if len(argv) < 1: print("usage:", sys.argv[0], "file_dir percentage") sys.exit() input_file = argv[0] process_file(input_file, noop_functions)