How do I write to a .csv file with python -
i writing simple script python3.6 , using csv module create csv file. code attached below, , carbon copy of multiple examples have found online, when run code, error message typeerror: bytes-like object required, not 'str'
.
import csv file_name = test.csv open(file_name, 'wb') csvfile: filewriter = csv.writer(csvfile,delimiter=',') filewriter = writerow(['paul','mary'])
if don't need binary mode, can use :
with open(file_name, 'w') csvfile: filewriter = csv.writer(csvfile,delimiter=',') filewriter.writerow(['paul','mary'])
check table here see details different modes available.
Comments
Post a Comment