Append an Array on LabVIEW to an Existing 2D Array Binary File

Updated Nov 3, 2020

Reported In


  • LabVIEW

Operating System

  • Windows

Issue Details

  • When trying to append data to an existing 2D array on each iteration of a loop the data is overwritten. For example, a program generates an 4 rows, 500 columns array each loop iteration, but when the loop is finished and the binary file is opened there are only 4 rows, 500 columns on the file, implying the file is overwritten on each iteration. The set position to an end node is used inside the loop as shown in the following code:
  • When the read to binary file function is used in the following code the file size grows but it is not correctly displayed in one 2D array.



  • Set your file position to the end just once outside the loop where you open the file, avoiding using it every time inside the loop.  As long as the file is not closed during the execution, the file system knows where the current file pointer is.
  • Use the input connector called count on the Read Binary File with the input -1 to read the entire file.  When this connector is not wired up, the default value is 1 and it reads 1 element (your 2-D array) from the file.  If you wire up another number you get more.  If you wire up -1, you read the entire file. If you wire up a number, you get a 1-D array of a cluster of your data (the 2-D array).  So if you read data this way, you can index the array, unbundle the cluster, then build the resulting 2-D array concatenating it a shift register.
  • Use a while loop and the read binary file node