LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from File

Solved!
Go to solution

I want to read any all the data in a file line by line. I'll be writing the data to arrays and plotting the data eventually. Once all the data is read in I want to wait a minute and read any new data that has been added to the file. I only expect the file to be updated once per minute with one line of data. The problem I'm dealing with is that once I close the file and then open to read again it starts at the beginning, which I do not want. Is there a way to give write priveledges to another program for the data file without it being closed by labview? This way I hope to have it read each new line without starting at the beginning. Right now i'm using the Read from Text File function which does not have a file location input. Is there a way to use this or do I need to use a different function. I've attached my vi. Thanks in advance for any help.

 

ssmith

0 Kudos
Message 1 of 5
(2,879 Views)

Sorry forgot to attach file

 

ssmith

0 Kudos
Message 2 of 5
(2,878 Views)
Solution
Accepted by topic author ssmith490D

@ssmith490D wrote:

. Is there a way to give write priveledges to another program for the data file without it being closed by labview? 



Not that I know of.

 

What you can do is store the file position after you finish you last read and store it in a shift register.  When you reopen the file, use Set File Position to set the file position and begin reading from there.

0 Kudos
Message 3 of 5
(2,872 Views)

@ssmith490D wrote:

I want to read any all the data in a file line by line. I'll be writing the data to arrays and plotting the data eventually. Once all the data is read in I want to wait a minute and read any new data that has been added to the file. I only expect the file to be updated once per minute with one line of data. The problem I'm dealing with is that once I close the file and then open to read again it starts at the beginning, which I do not want. Is there a way to give write priveledges to another program for the data file without it being closed by labview? This way I hope to have it read each new line without starting at the beginning. Right now i'm using the Read from Text File function which does not have a file location input. Is there a way to use this or do I need to use a different function. I've attached my vi. Thanks in advance for any help.

 

ssmith


Is your other program also a LabVIEW program? If so, you may be able to hold the reference in an action engine in your program (I pretty much always do file operations in an action engine), open an application reference from program #2 and access the functional global directly. But, from the sound of your post, your other application is not in LabVIEW, in which case Raven's solution is best.

0 Kudos
Message 4 of 5
(2,858 Views)

Thanks Ravens Fan. I appreciate the help.

0 Kudos
Message 5 of 5
(2,836 Views)