LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary file write cancatenation during writing

Hi, 

I'm trying to write a 2D array into a binary file and save the whole complete array in 2D.  As shown in the picture, data is written and appended to the binary file during each loop.  However, each loop would generate a 5x800 2D array (5 rows, 800 elements in each row).  Right now I have to use another vi to process the binary file I saved to concatenate all the arrays in the binary file to finally obtaion a 5 x 800n (n is the number of loops) array.  Is there a way to save the data into binary file in that format during each loop instead of writing into different segments and I have to concatenate different segments together after that?  

On the other hand, if there's a way to do that, would that increase the loop cycle time because it's more computationally expensive?  Thank you very much for your help.

 

Thank you,

Charles

 

 

0 Kudos
Message 1 of 4
(2,105 Views)

See the attached examples.

 

If you have the file open you can basically just write data to it whenever you have it available, just do not include the length. It can cost a bit to write single elements so the row option is more commonly used, but it depends on how large each row is (if they are huge then it will cost to much to keep them in memory and you write parts of each row instead...). 

 

I have not covered cases where you need to close the file and add data later, but the difference then is just that you need to set the write position after you have re-opened the file.

0 Kudos
Message 2 of 4
(2,098 Views)

So does it mean instead of just wire it, I need to create a register?  What's the difference between the two cases?  In the picture I attached, I assume that the file is only opened once and then data is written to the file during each loop, until the loop ends, and then the file is closed.  

By the way, YES, in each row, after I concatenate the whole file, I actually have millions of data points in each row.  Would it be better not to use register?  

Thank you so much for your reply.  

 

Best,

Charles

0 Kudos
Message 3 of 4
(2,096 Views)

Not sure what you mean. If you are refering to the shift registers in my example then they are not really needed there, but in cases where you do not know how many times the loop will run you avoid losing the file reference if the loop count is zero...so it's just a good rule of thumb to do it the way I did.

 

In the last picture you seem to write in an OK fashion with the exception that you are including a length flag....that's fine if you want to write out the content of the file as a series of 2D arrays though...but if you want to treat it as a single 2D array then adding a length on each write will mess things up.

0 Kudos
Message 4 of 4
(2,089 Views)