02-20-2022 02:57 AM
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.
Solved! Go to Solution.
02-20-2022 03:08 AM
02-20-2022 03:35 AM
yes, this mean if I use 64 bit, it will work
02-20-2022 08:10 AM
02-20-2022 06:07 PM
@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.
02-20-2022 06:56 PM - edited 02-20-2022 07:01 PM
@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.
02-21-2022 04:15 AM
@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!
02-21-2022 05:35 AM
thanks for your attention.
I solve the problem by reading chunks of data file.
02-21-2022 08:39 AM
02-21-2022 09:51 AM
@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. 😄