I would like to save my strings into a csv file. Given the code below, there is a closed file issue, how can I save the list of strings into csv file? I don't understand why is this not working.
Code
import csv
with open('onehot.csv','wb') as testfile:
csv_writer=csv.writer(testfile)
collection = ['hey', '5', 'd']
for x in collection:
csv_writer.writerow(x)