One possibility is to create a named pipe and to write to the named pipe from the same script that appends to the file. You could then have your J process read from the named pipe, when data was available, it should wake up and process the data without delay. The other possibility is to write only a single byte (or word, say the size of the file before you appended to it) to the pipe, and have the process then read the file from that point on to the end.
The "poll once a second" idea is not a bad one, that, as I understand it, is how "tail" works, it stats the file (by name or identifier depending on how it was called) to see if the file has been moved or changed. But some people don't want to wait, and stock market stuff might not be able to deal with a polling delay, considering how some people try to "middle" trades with servers on the floor to limit communication delays. Something like fuser could make sure that there is a sink so that you don't fill the pipe with data that will eventually block you - or just use a non-blocking write. The "position of the file before you wrote to it" can be used to sync. You could have a bunch of writes stacked and when you read one and process from there to the end of the file, you can ignore any that are lower than that synching point. On Sun, Dec 18, 2011 at 11:13 AM, <elmer_...@antelecom.net> wrote: > I need to process a file with the following structure. > > 10:14:44,0.3540,-0.0290,134988,-7.57,0.3610,0.3420,0.3343,0.3830 > ,0.3500,0.3710 > 10:16:44,0.3540,-0.0290,134988,-7.57,0.3610,0.3420,0.3343,0.3830 > ,0.3500,0.3710 > 10:22:45,0.3540,-0.0290,134988,-7.57,0.3610,0.3420,0.3343,0.3830 > ,0.3500,0.3700 > > Every minute, if the detailed quote changes, a new row > detailed quote information > is appended to the file. In this case the data is for a > stock UURAF. > > The data is collected by using a bash script containing awk > routines. > > I want to process the information in real time. As an > example, I would like to > calculate the moving average for the last 5 and last 10 > trades. > > My first guess would be to initialize an empty array and as > new data comes in insert > it into the array. When the array changes, I would > recalculate and display the result. > > My question is: > > How do I add data in real time (when I get new data appended > to my comma > file ) to a J array that I can process? > > thanks > > > > > > > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Of course I can ride in the carpool lane, officer. Jesus is my constant companion. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm