import sys def split_columns(input_file): columns = [] with open(input_file, 'r') as f: for line in f: parts = line.strip().split(',') for i, part in enumerate(parts): if len(columns) <= i: columns.append([]) columns[i].append(part) for i, column in enumerate(columns): with open(f"{input_file[:-4]}_column_{i + 1}.txt", 'w') as outfile: outfile.write("\n".join(column) + "\n") if __name__ == "__main__": for input_file in sys.argv[1:]: split_columns(input_file)