LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save data string in binary file

Hi,
I have lots of messages (string) that I receive via DataSocket that I want to save (~100 messages/second). I have been working until now with Write Characters to File but I'm not sure that it is optimum. In 5 minuts my file (.txt) have 1,5 Mb.  There are another method to save all the messages? I've read that convert to binary is better. It's faster, too?(Write characters to file is continuously working and it slow down all vi working)
 
Thank you.
 
Vicens
 
LV 7.1 / XP
0 Kudos
Message 1 of 8
(4,289 Views)
Hi Vicens,

yes, using 'Write Chars to file' is not optimal.

First: try to collect data before writing to file instead of writing each small message seperately. For instance you can collect messages upto 1 million chars and write the resulting string. Avoid 'concat string' (same as 'build array') due to memory handling issues. Better use a 'replace array subset' approach.

2nd: Try to open your data file first (before data aqu starts), then write the data using any binary method. Close the file after daq stopped. 'Write chars to file' will open and close the file each time you call the function...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(4,270 Views)

Thank you, GerdW.

 

0 Kudos
Message 3 of 8
(4,250 Views)

I'm sorry I disturb you, but I'm trying to use Binary File VIs and I cannot use it. I've created an array with all my messages but I cannot wired to fuction (write to SGL or write to I16). It's because my array is string, no data.

Vicens

 

LV7.1 / WinXP

0 Kudos
Message 4 of 8
(4,245 Views)
Hi Vicens,

in LV8.2 you can wire any datatype to 'Write to Binary', including string and U8-array. First convert your array of strings to one long string by using 'concat string' or even better collect your messages in one long string instead of creating an array...

In LV upto 7.1 you can use the 'Write File' function. Here you can also wire a string or an U8 array. For generating the data the same applies as above!

Just have a look inside the 'Write characters to file' function to see how it's done!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 8
(4,244 Views)
Thanks, I found it.
0 Kudos
Message 6 of 8
(4,238 Views)
Hi all,
 
Thanxs both for your good interaction,
 
just a couple of things:
1. Remember when writing a binary file that u write data without format (binary) to save space, so take in consideration the kind of data u ar writing for reading it afterwards properly.
2. If you are experiencing problems with the speed its ok u look for that, if not just consider that the file size limitation is windows and it is 1 Gbyte for a file,
 
 
Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Message 7 of 8
(4,233 Views)
Actually, the limit for LV7.1 is "normally" 2GBytes, since LV7.1 uses 32bit signed pointers for file access.  However, there is an easy way around this in WinXP, provided your file system is NTFS, not FAT32 (it is, isn't it Smiley Wink).  You can find complete directions and code examples in the tutorial Managing Large Data Sets in LabVIEW.  Click on chapter 5 in the table of contents to take you to it.  Note that the HDF5 utilities mentioned in that tutorial make an excellent binary file storage mechanism, although the learning curve is more than a bit steep.
0 Kudos
Message 8 of 8
(4,223 Views)