For example, when you want to output the scraped information in csv format and go to Excel.
csv.py
# -*- coding: utf-8 -*-
import csv
#File open
f = open('output.csv', 'w')
writer = csv.writer(f, lineterminator='\n')
#Keep data in list
csvlist = []
csvlist.append("hoge")
csvlist.append("fuga")
#output
writer.writerow(csvlist)
#File close
f.close()
By the way, if the second argument of file open is ʻa`, it will be in append mode.
Recommended Posts