LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spreadsheet files and binary files

I've just started learning about binary files using Labview 8.5.  I tried converting a text spreadsheet file with numbers like below (about 1000) to a binary file and then read that file in to see if it's working correctly.  Seems to be doing so except that the binary file is slightly larger than the original text file.  I thought that binary files were much smaller.  Am I missing something?  I've attached a picture of the code I've been playing around with.

 

250
0.105
-0.103
-0.115
0.145
-0.109
0.029
-0.126
-0.043

 

 

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

Hi ratkindler,

 

writing DBLs to a binary file needs 8 bytes per value, writing 1000 DBLs will need atleast 8kB...

When writing the same numbers as Spreadsheet file using a format like "%6f" will also need 7-8 chars per number resulting in slightly less than 8kB for the same array.

 

Binary files might be smaller when the textfile contains the numbers in same high precision (like %16)... Think about it...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,522 Views)
So the size is about the same, but will reading/writing binary files with these numbers be about the same too?
0 Kudos
Message 3 of 13
(3,504 Views)

Hi ratkindler,

 

binary file will allow for higher precision with same file size!

 

Don't know what you are asking about file operations...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(3,487 Views)

Hi ratkindler,

 

The resulting size of the file is dependent on the data and the datatype being written.

 

For example, if you had a 100 DBLs with a value of 1000, writing that to a binary file would still result in a file size of 100 * 8 bytes = 800 bytes. However, if you had 100 U8s with a value of 1000, writing that to a binary file would result in a file size of 100 * 1 byte = 100 bytes.

 

If you were to write the data from either scenario to a text file, each digit would have to be converted to its ASCII representation and would result in a file size of 100* 4 bytes (1 byte per digit) = 400 bytes.

 

Please let me know if you have any questions. Thanks!

 

Aaron P

National Instruments

Applications Engineer

http://www.ni.com/support

0 Kudos
Message 5 of 13
(3,444 Views)

Aaron,

 

How do you get a value of 1000 into a U8? 

 

Lynn 

Message 6 of 13
(3,436 Views)

Hi johnsold,

 

Touché Smiley Very Happy. Thank you for pointing out my momentary mental lapse. How about a value of 256 instead of 1000? The idea is still the same, except the resulting text file would now be 300 bytes instead of 400.

 

Aaron P

National Instruments

Applications Engineer

http://www.ni.com/support

0 Kudos
Message 7 of 13
(3,433 Views)

Hi Aaron,

 

256 is still to big for U8. Smiley Wink

 

And your text file will have a size of 399 bytes due to delimiters between numbers...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 13
(3,417 Views)

Aaron,

 

It is Monday.  Too much weekend? Or, not enough?

 

We do appreciate your effort to explain the differences in file sizes.

 

Lynn 

 

 

0 Kudos
Message 9 of 13
(3,410 Views)

Haha wow. My brain really is taking some time to get going. How about 100 instead of 256? I think that should work. Smiley Tongue

 

And GerdW, thank you for pointing out the delimiters.

 

Aaron P

National Instruments

Applications Engineer

http://www.ni.com/support

0 Kudos
Message 10 of 13
(3,400 Views)