LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading arrays from binary files

Hi,
I am writing an array of size three into a binary file. At regular intervals I wish to read this binary file, and wish to read it in the format of an array of size three. i.e. I wish to get back the data in the same format as it was written. For example: my data is [1 2 4],[1 2 5], ... ->> after writing a file and then reading from it I should again get [1 2 4],[1 2 5], ...

However I am unable to read this binary file again. (Exit Error code = 4). Attached is the file that explains my problem.

I have succesfully used such a method for writing and reading "I32" variables and even "Double" variables. But am unable to do so with arrays .

Thanks in advance.
0 Kudos
Message 1 of 4
(2,984 Views)
Hello tsheikh,

it seems to be a problem of LabView misinterpreting
your data type (see LabView help for "Read File").
If you just use an array and not a cluster, why not
use the normal ReadFile to read the needed number of elements?
As workaround I would write a subvi with 2 arguments:
filename and number of elements to read...

Best regards
Gerd
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,984 Views)
When you write the array to file, wire the header input to True. This way, the array length will be written on file and you'll be able to retrieve data as an array.


LabVIEW, C'est LabVIEW

Message 3 of 4
(2,984 Views)
Hi,
I have attached a couple of VIs that are altered versions of examples that ship with LabVIEW. The VIs allow you to write binary data to file and read binary data from file.

I hope this helps.

Sincerely,
Feroz
National Instruments
Download All
0 Kudos
Message 4 of 4
(2,984 Views)