Read and Write an N-Dimensional Array to a File in LabVIEW

Updated Aug 21, 2023

Reported In

Software

  • LabVIEW

Issue Details

I would like to write a N-dimensional array to a file and be able to read it in LabVIEW. How can I accomplish this?

Solution

You can write your n-dimensional array to a file using the Write to Binary File  function by wiring the array into the data input terminal. When reading back this file, use the Read from Binary File function and wire an array of the same data type to the data type input terminal. Both of these function are available in LabVIEW 8.0 and later and can be found on the File I/O pallette.

If you are using LabVIEW 7.x or earlier:
  • Use the Write File VI and wire the N-dimensional array into the data input.
  • Wire a true Boolean constant to the header input terminal, this creates a header that stores information about the dimensions of the array. 
  • When reading back this file, use the Read File VI and wire an n-dimensional array constant of the same data type to the byte stream type input terminal. 

Additional Information

It is important to keep in mind that LabVIEW writes the data in Big-Endian format; therefore to read binary files in a different application you must convert the data to Little-Endian form.