由於某些原因,它不會寫入CSV。任何人都可以看到它爲什麼不寫?寫入CSV
def main():
list_of_emails = read_email_csv() #read input file, create list of emails
master_list_writer = open_master_list() #open output file so we can write to it
.....
write_to_csv(master_list_writer, list_of_url, linkedin_information, facebook_information, twitter_information)
def open_master_list():
final_csv = open('ruby_dev_final1.csv', 'wb')
output_writer = csv.writer(final_csv)
return output_writer
def write_to_csv(master_list_writer, list_of_urls, linkedin_information, facebook_information, twitter_information): #add in linkedin_list
master_list_writer.writerow(list_of_urls + linkedin_information + facebook_information + twitter_information)
print list_of_urls, linkedin_information, facebook_information, twitter_information
print 'is this working?'
return
這是打印出來:
['[email protected]', u'Cincinnati Area', u'http://www.facebook.com/jimweirich', u'http://www.linkedin.com/in/jimweirich', u'http://twitter.com/jimweirich'] ['Jim', 'Weirich', 'Chief Scientist', 'Neo', 'Cincinnati Area', 'P1Y10M', 'Present'] ['', '', ''] ['', '', '', '']
is this working?
你的代碼肯定是寫CSV,但我猜你不知道*目錄*在哪裏寫的地方恩。在你的調試輸出中添加一個'print os.getcwd()',然後查看*那個*位置。 –
在write_to_csv中,您需要調用master_list_writer.close() –
@RyanG:closing是可選的;它在腳本退出時自動發生。 –