''' Python function that can transform the rows of a CSV file containing first and last names into rows with only the initials of those names ''' import csv def transform_names_to_initials(input_file, output_file): with open(input_file, 'r') as csv_file: reader = csv.reader(csv_file) with open(output_file, 'w', newline='') as output_csv: writer = csv.writer(output_csv) for row in reader: initials = [] for name in row: name = name.strip() if name: initials.append(name[0]) writer.writerow(initials)