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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -