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

Updated Jul 20, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

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

LabVIEW 8.0 and Later:
Use the Write to Binary File function and wire the 3-dimensional array into the data input terminal. 



When reading back this file, use the Read from Binary File function and wire a 3-dimensional array of the same data type to the data type input terminal.



Both the Write to Binary File and the Read from Binary File functions can be found on the Functions Palette under File I/O.



LabVIEW 7 and Earlier:
Use the Write File VI and wire the 3-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 a 3-dimensional array constant of the same data type to the byte stream type input terminal. 
The same concept applies for n-dimensional arrays. When an n-dimensional array is written to a file, a n-dimensional array of the same data type must be wired to the data type input terminal of the Read from Binary File function or the byte stream type input terminal of the Read File VI.
 

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. Refer to the link below for more information.

WAS THIS ARTICLE HELPFUL?

Not Helpful