【发布时间】:2016-08-16 15:24:55
【问题描述】:
当我使用下面的代码时,我的数据被导出,但它全部在一列中一直向下,有什么帮助吗?
b = open('tester.csv', 'wb')
a = csv.writer(b)
while (count < x):
tags = str(data['alerts'][count] ['tags']).replace("u\"","\"").replace("u\'","\'")
a.writerows(strList)
【问题讨论】:
-
strList在哪里定义?此外,样本数据也会有所帮助。 -
什么是
strList?它应该是行的集合 (['r1', 'r1c2'], ['r2', 'r2c2']])。 -
是的,它是一组打印数据的行,例如 ['hi', 'yes', 'bye', 'def'] ['hi', 'ast', 'cnx', ' vplex'] ['ever', 'as', 'no', 'qwerty', 'redi'] ['no', 'yes', 'qwerty'] ['redi', 'google'] ['redi' , 'asdf', 'asdfef', 'wer'] ['redi', 'asd', 'rrr', 'www', 'qqq'] ['erfa', 'asdf', 'fef'] ['hi ', 'dsa', 'f3e']
-
@Jsant:这就是您的想法,但您遇到的问题表明并非如此。查看
print strList的输出,您可能会发现它不是列表列表。
标签: python csv export-to-csv