Reputation: 3215
I'm trying to convert a list to a csv.
import csv
import pandas as pd
cikList = []
with open('/home/a73nk-xce/PycharmProjects/SP500_list/stockChar/CIK.csv', 'r', newline='') as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
for 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 this code I return the following:
TypeError: 'str' does not support the buffer interface
Upvotes: 0
Views: 57
Reputation: 3215
Change:
myfile = open('newCIK.csv', 'wb')
To:
myfile = open('newCIK.csv', 'w')
Upvotes: 1