Python: Write csv header "with open" -
i have following code generate csv file without using csv module, , wondering best way header file:
for language in languages: open ('user_edits.csv', 'a') f: f.write(str(user_count)+","+str(language[0])+","+str(language[1])+","+str(language[2])+"\n")
open file once , use csv module's functions:
import csv open ('user_edits.csv', 'a') f: writer = csv.writer(f, delimiter=',') language in languages: writer.writerow([user_count]+language[:3])
Comments
Post a Comment