08-17-2009 10:30 AM
I am trying to write to, and then read back, an array of data to an ASCII file. I have tried various methods over the past few weeks and I am now frustrated. I have tried methods including the one I show in the BMP file attached and also by simply using the LV Read and Write to Measurement File. Both methods work great but are much, much too slow.
Using either method takes a few seconds to write the array of values and then read them back in. I am trying to do this in near real time (the write is much more ciritcal). There are always the same number of data points in the array(110+points) and if I were to write this file using standard "C" I could accomplish the write in near real time. I therefore feel that I should be able to do the same in LabView if I used the proper functions.
Any suggestions on speeding this up significantly?
08-17-2009 10:50 AM - edited 08-17-2009 10:56 AM
Here's a basic example. I have not benchmarked it but my guess is that your calling the Format Into File and Scan From File multiple times is where you have made the biggest mistake.
08-17-2009 10:53 AM
Your fundamental (though not only) problem is that you are doing a file I/O operation each time you iterate through the loop. This is expensive, in any programming language. If your arrays are not large enough, then the best way to do this is to read/write out the array all at once. For this you could simply use Read From Spreadsheet File and Write to Spreadsheet File. An even faster method is to simply use binary files. This skips the formatting to string. See the shipping examples on reading/writing binary files.
Code comments: