簡體   English   中英

由python寫出的CSV在Excel中完全空白

[英]CSV written out by python is completely blank in Excel

我有一個簡單的字典,我正在寫一個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.

謝謝!

感謝你的幫助! 這是用戶錯誤,但回答您的詢問幫助我抓住了自己。 在關閉它之前,我正在將文件發送到某個地方。 咄...

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])

沒有什么可寫的,所以文件是空的

應該不應該使用quoting = csv.QUOTE_NONE

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM