| import csv |
|
|
| def process_csv(input_file, output_file): |
| with open(input_file, 'r') as csvfile: |
| reader = csv.reader(csvfile) |
| next(reader) |
|
|
| output_data = [] |
|
|
| for row in reader: |
| word, score = row[0], int(row[1]) |
| if score == 1: |
| |
| for letter in word: |
| output_data.append([letter, '1']) |
| else: |
| output_data.append([word, str(score)]) |
|
|
| with open(output_file, 'w', newline='') as csvfile: |
| writer = csv.writer(csvfile) |
| writer.writerow(['Letter', 'Score']) |
| writer.writerows(output_data) |
|
|
| if __name__ == "__main__": |
| input_csv = "word_scores.csv" |
| output_csv = "word_scores2.csv" |
|
|
| process_csv(input_csv, output_csv) |
| print(f"Conversion complete. Output saved to {output_csv}") |
|
|