LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Binary File Function Append to existing file.

Solved!
Go to solution

Hi, I've got problem with writing to a binary file with Binary File Function.  I'd like to append the array to the existing file during each loop.  My program generate a 4 row, 500column 2D array during each loop.  However, after I stop  the vi and open the binary file, there are only  4 row, 500column data in the file.  I assume it's becuase in each loop the data is overwritten.  I've already used Set file position to End.  I don't understand why it still overwrites my file.  Thank you very much.

 

 

 

0 Kudos
Message 1 of 11
(8,397 Views)
Solution
Accepted by topic author soljiang

It seems to work okay for me.  How do you know it only has one set of data in it?

 

You could actually set your file position to the end just once outside the loop where you open the file, you don't need to do it every time in the loop.  As long as you don't close the file, the file system knows where the current file pointer is.

Message 2 of 11
(8,384 Views)

Because I used another vi "binary file reader" to read the file.  I only get 4 row and 500 elements in each row.  That corresponds  to one loop only.  I let the vi run many loops before I stopped it.  

0 Kudos
Message 3 of 11
(8,379 Views)

 


@Ravens Fan wrote:

It seems to work okay for me.  How do you know it only has one set of data in it?

 

You could actually set your file position to the end just once outside the loop where you open the file, you don't need to do it every time in the loop.  As long as you don't close the file, the file system knows where the current file pointer is.


 

Hi, Ravens,

I think you are right....   The file size does grow with the time that I collect data.  So I think all the data is in the file.  Somehow I can't read them out.  They might be segmented due to each loop.  Do you have any suggest how to read them all out into one 2D array?  Thank you so much.

 

Best,

Charles

0 Kudos
Message 4 of 11
(8,372 Views)

Yes.  The Read Binary File has an input connector that is called Count.  When it is not wired up, the default value is 1 and it reads 1 element (your 2-D array) from the file.  If you wire up another number you get more.  If you wire up -1, you read the entire file.

 

If you wire up a number, you get a 1-D array of a cluster of your data (the 2-D array).  So if you read data this way, you can index the array, unbundle the cluster, then build the resulting 2-D array concatenating it a shift register.

 

Message 5 of 11
(8,368 Views)

You can also read the file one piece of data at a time if you do it inside a loop.

 

 

Message 6 of 11
(8,364 Views)

Thank you so much! I wanted to concatenate the array horizontally, but I figure that out with your help.  Thanks  a lot!!!

0 Kudos
Message 7 of 11
(8,341 Views)

hi how to append the binay file using the file path...

 

 

Thanks in advance

0 Kudos
Message 8 of 11
(7,856 Views)

I don't understand your question.

 

Rather than hijacking a year and a half old thread, you'd be better served to start your own new thread.  Be sure to provide some detail with your question.  Perhaps post your VI so we can see what you are doing and tell us where you are having problems.

0 Kudos
Message 9 of 11
(7,853 Views)

ya sure please see the attached file actually i am opening the excel workbook and write in to binay file and if i open the next workbook that value should append to the same binay file and like that i have append the many excel (Tab delimited)

 

 

Thanks in advance

0 Kudos
Message 10 of 11
(7,849 Views)