How can we convert a .txt file into a CSV python script file?
Here, I'm trying to convert it:
import csv
import itertools
with open('log.txt', 'r') as in_file:
stripped = (line.strip() for line in in_file)
lines = (line for line in stripped if line)
grouped = itertools.izip(*[lines] * 3)
with open('log.csv', 'w') as out_file:
writer = csv.writer(out_file)
writer.writerow(('title', 'intro'))
writer.writerows(grouped)
But, In the output, I can get only the title, intro, and tagline
I need the log.csv file to show:
title,intro
2.9,Gardena CA