I\'m trying to write the values of an array to a .csv file in python. But when I open the file in excel, the data is shown in one row. I want to have one column where each m
Try this:
import csv
import numpy as np
yourArray = ['deer', 'airplane', 'dog', ..., 'frog', 'cat', 'truck']
yourArray = np.array(yourArray)
with open('outputFile.csv', 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',')
for row in range(0,yourArray.shape[0]):
myList = []
myList.append(yourArray[row])
writer.writerow(myList)