LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract data from a file while still being written

Hi,

 

I have a DAQ program which writes measurments to a text file. I need to write a parallel program in LabVIEW which takes the data from the text file every 2 mintues, and writes it to a new text file with another name. actually I would like to split the data text file to multiple sub-files during DAQ while the text file is still being written.

 

given the file path and name, is this program possible ? 

 

Thanks,

Lior.

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

Nothing says you can't the data to two files at the same time.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 4
(2,577 Views)

@Lior_Bachar wrote:

 

 

given the file path and name, is this program possible ? 

 

Thanks,

Lior.


It depends how the DAQ program opens the file!

 

When opening a file, an application can define if other processes should be able to read, write or not access the file while it is open. And there is no legal way short of exploiting some unfixed bug in some Windows API to overrule that by another application.

 

Even if your DAQ program allows read access by other processes, it could be getting a tricky exercise to make sure you keep the data consistent when reading the file while the DAQ program writes to it.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 4
(2,563 Views)

I was thinking about "how to do this" and writing some Test routines to try out some schemes when I realized that Billko's suggestion makes the most sense.  I always think "Producer/Consumer" when spooling data to disk files, and the same applies here.  Your Consumer initializes itself by opening "Two Minute File 1" and "Entire Record File", and sets a counter or timer to decide when the close "Two Minute File N" and open "Two Minute File N+1".  Inside the loop, it writes the data to both files, updates the counter/timer to decide if the Two Minute File needs to be closed and a new one opened, then continues until the Producer signals that it has finished.

 

One "trick" in P/C models is how to tell when the Producer finishes.  The Producer does not want to "kill the Queue" (a crude, sometimes-effective signaling method), as the Consumer may still be using it.  So the Producer, after it exits the Producer Loop, puts one last element (traditionally called a "Sentinel") on the Queue, something that otherwise would never appear.  Here, since you're passing an array of data, pass an empty array.  In the Consumer loop, test the Array to see if it is empty.  If it is not, send it to the two Disk files.  If it is empty, then you have finished the Producer Loop, so you can exit the Consumer loop, release the Queue, close the files, and prepare to finish your Main Routine.

 

Bob Schor 

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