LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from Binary File

Solved!
Go to solution

dear all,

I try to read data from a binary file with size large than 2 Gigabytes but the read from binary file component in labview give me the error attached in picture.

note : when I use less size like 1 K bytes it work correct. 

0 Kudos
Message 1 of 13
(1,927 Views)

Are you  using 32 bit LabVIEW?

That only supports 2Gig.

greetings from the Netherlands
0 Kudos
Message 2 of 13
(1,922 Views)

yes, this mean if I use 64 bit, it will work

0 Kudos
Message 3 of 13
(1,908 Views)

Just try.

greetings from the Netherlands
0 Kudos
Message 4 of 13
(1,896 Views)

@Albert.Geven wrote:

Are you  using 32 bit LabVIEW?

That only supports 2Gig.


An array is still limited in size by the I32 index.  So that could still be an issue depending on the data type.

 

But looking at the error image, it is looking like the file is never actually opened (at least that we can see from the tiny bit shown in the image).  Error code 1 would make sense for an invalid file reference.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 13
(1,884 Views)

@AH.Samir wrote:

I try to read data from a binary file with size large than 2 Gigabytes but the read from binary file component in labview give me the error attached in picture.

note : when I use less size like 1 K bytes it work correct. 


(I am not sure why you are posting this in the instrument control forum, because it has nothing to do with instrument control. I moved the thread to the LabVIEW board).

 

You can read files larger than 2GB, but you are leaving out important information. What is the datatype?

(All we can tell from the picture is that it is a blue datatype and since you wire the size it might be U8, but we cannot really tell if all code is reasonable. For example, you can read the entire file even without getting the size first, so this part is quite pointless!)

 

For example U64 has 8 bytes/element, so a 2GB binary file would only have ~256k elements, well within the limits of LabVIEW where the number of elements are limited to I32 indices (~2G elements).

(but you definitely need 64bit LabVIEW! Arrays need to be contiguous in memory, so you need a contiguous chunk of 2GB free for just one copy. Impossible for 32bit LabVIEW).

 

As has been pointed out, there might be something wrong with the file name. Does it contain any unusual characters (e.g. unicode?).

 

Can you tell us a little bit about your application? Do you really need to read the entire file into memory or could you process it in chunks? What kind of processing is involved? Are you planning to push all of it to the front panel (indicator, graph, etc.) That would seem highly unreasonable.

0 Kudos
Message 6 of 13
(1,878 Views)
Solution
Accepted by topic author AH.Samir

@AH.Samir wrote:

yes, this mean if I use 64 bit, it will work


No, a LabVIEW array can't have more than 2^31 elements. So you can't read more than 2GB of U8 data at once. And as Altenbach pointed out if you try to read a 2GB array into 32-bit LAbVIEW it will certainly balk, as the entire LabVIEW process is limited to at most 3GB of user usable memory by the OS (it reserves 1GB for mapping its own system DLLs into the maximum 4GB memory space that can be addressed by a 32-bit pointer).

 

But you can read a 64 GB file in chunks of several 100kB per iteration without any problems. The LabVIEW file functions use internally 64-bit file offsets so they certainly can access files bigger than 2GB, just not in one go!

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 13
(1,821 Views)

thanks for your attention.

I solve the problem by reading chunks of data file.

 

0 Kudos
Message 8 of 13
(1,805 Views)

Thanks Rolf

That fact (64 bit file pointer) helps me too.

greetings from the Netherlands
0 Kudos
Message 9 of 13
(1,784 Views)

@AH.Samir wrote:

I solve the problem by reading chunks of data file.

 


Just reading a file is relatively boring, it really depends on the required processing of that data. 😄

 

 

0 Kudos
Message 10 of 13
(1,770 Views)