【发布时间】:2014-02-23 06:49:48
【问题描述】:
我正在尝试将数组的值写入 python 中的 .csv 文件。但是当我在 excel 中打开文件时,数据显示在一行中。我想要一列,其中数组的每个成员都是一行。
数组“testLabels”的格式为:
array(['deer', 'airplane', 'dog', ..., 'frog', 'cat', 'truck'],
dtype='<S10')
我用来写入 csv 的代码是:
import csv
resultFile = open("/filepath",'wb')
wr = csv.writer(resultFile)
wr.writerows([testLabels])
任何帮助将不胜感激。
【问题讨论】:
-
这个问题早就得到了关于python方面的建议的回答。但是,在 MS Excel 中使用函数会更容易:只需使用 text-to-columns function。
标签: python arrays excel csv machine-learning