python 3.x - Python3.4 : List to CSV -
i'm trying convert list csv.
import csv import pandas pd ciklist = [] open('/home/a73nk-xce/pycharmprojects/sp500_list/stockchar/cik.csv', 'r', newline='') csvfile: spamreader = csv.reader(csvfile) row in spamreader: eachrow in row: eachrow = eachrow.lstrip('0') ciklist.append(eachrow) myfile = open('newcik.csv', 'wb') wr = csv.writer(myfile, quoting=csv.quote_all) wr.writerow(ciklist)
when running code return following:
typeerror: 'str' not support buffer interface
change:
myfile = open('newcik.csv', 'wb')
to:
myfile = open('newcik.csv', 'w')
Comments
Post a Comment