Excel中由Python写出的CSV是完全空白的
我有一个简单的字典,我正在写一个CSV文件,它看起来很好,当我在服务器上查看它,但它是完全空白的Excel。
csvOutput = {'http://www.test.com/': 'This source is currently in the system.', 'http://test.com/': 'This source is not currently in the system.', 'http://www.test.com/': 'This source is currently in the system.'} writer = csv.writer(open(csvFileName, 'wb'), quoting=csv.QUOTE_NONE, dialect='excel') for key, value in csvOutput.items(): writer.writerow([key, value])
谢谢你的帮助!
这里是我在vim中看到的文件:
http://www.test.com/,This source is currently in the system. http://test.com/,This source is not currently in the system. http://www.test.com/,This source is currently in the system.
谢谢!
感谢你的帮助! 这是用户错误,但回答你的询问帮助我了解自己。 在我closures之前,我正在把文件发送到某个地方。 咄…
for key, value in csvOutput.items(): writer.writerow([key, value]) f1.close() # I hadn't closed it here. f2 = open(csvFileName) jira.add_attachment(issueKey, f) f2.close()
谢谢!
如果你的代码是
csvOutput={} writer = csv.writer(open(csvFileName, 'wb'), quoting=csv.QUOTE_NONE, dialect='excel') for key, value in csvOutput.items(): writer.writerow([key, value])
没有什么可写的,所以文件是空的
引用= csv.QUOTE_NONE可能不应该使用