1import csv
2
3with open('log.txt', 'r') as in_file:
4 stripped = (line.strip() for line in in_file)
5 lines = (line.split(",") for line in stripped if line)
6 with open('log.csv', 'w') as out_file:
7 writer = csv.writer(out_file)
8 writer.writerow(('title', 'intro'))
9 writer.writerows(lines)