Read numeric data from a binary file in LabVIEW by using the Read from Binary File function and specifying the matching data type of the binary data to read.

To read numeric data from a binary file, complete the following steps.

  1. Write to a binary file to create the .bin file you need to complete the following steps.
  2. Add the Read from Binary File function to the block diagram.
  3. Wire the data type of the logged data to the Read from Binary File function.
    1. Add a numeric constant to the block diagram.
    2. Wire the numeric constant to the data type input of the Read from Binary File function.
    3. To tell LabVIEW the data type that you want to read, enter a value into the numeric constant.

    The value you input determines which data type LabVIEW interprets. For example:

    • By default, LabVIEW interprets 0.0 as a double-precision, floating-point number.
    • By default, LabVIEW interprets 0 as a long signed integer.

    You can also right-click the constant and select a Representation option to define the data type.

    You can also wire an array to the Read from Binary File function.

  4. Right-click the data output of the Read from Binary File function and select Create » Indicator.
  5. Run the VI.
  6. In the dialog box that appears, select a binary file with a value that corresponds to the data type you specified.
    Presenting a dialog box to choose a file is the default behavior of Read from Binary File if the file input is unwired.

Reading Binary Files Examples

For information about reading binary data and placing it into a pre-allocated array without incurring a copy, refer to the Preallocated Read from Binary File function.

For an example of how to open and read an existing file stored as a double-precision array in binary form, refer to the Simple Binary File project in the labview\examples\File IO\Binary\Simple Binary folder.