To download NI software, including the products shown below, visit ni.com/downloads.
Overview:
This example show how to write CSV files by opening the file and leave it open until finished all of writing before finally closing the file.
Description:
We can easily write CSV files by utilizing the 'Write To SpreadSheet File.vi'. However, this function internally includes both the Open/Create/Replace and Close file functions. As such, these functions can lead to race conditions when utilizing the 'Write to SpreadSheet File' in a while loop. This is due to continually telling the operating system to open and close the file. In this manner, we may have a call to reopen the file when it is still open or perhaps in the process of closing leading to an error. The following code demonstrates how we can open the file and leave it open until we are finished with all of our writing before finally closing the file.
Requirements:
Steps to Implement or Execute Code
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.