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 member of the array is a row.
The array "testLabels" is of the form:
array(['deer', 'airplane', 'dog', ..., 'frog', 'cat', 'truck'],
dtype='<S10')
And the code I use to write to the csv is:
import csv
resultFile = open("/filepath",'wb')
wr = csv.writer(resultFile)
wr.writerows([testLabels])
Any help would be greatly appreciated.
Try this:
Try this:
You need to write each item of list to a row in the CSV file to get them into one column.
Try this:
You should change the delimiter. CSV is Comma Separated Value, but Excel understands that a comma is ";" (yeah weird). So you have to add the option delimiter=";", like