s-news
[Top] [All Lists]

scan(): could not skip lines

To: s-news@wubios.wustl.edu
Subject: scan(): could not skip lines
From: Don MacQueen <macq@llnl.gov>
Date: Mon, 11 Dec 2000 07:27:30 -0800
Splus 5.1 on Solaris.

I have a "process monitoring" type of task.
Data is being added to a file by an external non-Splus process, one record per minute.

My Splus script uses scan() to read the data into an Splus object, notes how many records were read, and periodically updates itself, using the skip argument of scan to get only the new records. "Periodically" means, say, once every 5 minutes. Eventually, the script will run in batch mode as a unix cron job.

Every once in a while, I get an error message like this:

Reading data from  rm_3.dat
Skipping first 5111 lines
Problem in scanDefault(file, what, n, sep = ",", skip = ..2): Could not skip 5111 lines in file

If I immediately restart the Splus script, it successfully reads the file,skipping the appropriate number of records.

I suspect what is happening is that occasionally Splus tries to read the file while it is being written to by the other process. I don't know how to test or confirm this suspicion.

Can anyone confirm my suspicion, or suggest a way to test my idea, or point me in the correct direction if I'm wrong?

My next step in solving this myself is to experiment with taking more control over the file opening and reading process, particularly the 'blocking' option to the file() and open() functions. Which leads to another question:

Does scan() used by itself in Splus 5.1 use the 'new' i/o system, e.g., the connection class, or does it use some older method? If it uses the new method, does it set blocking=T or blocking=F?

Chapter 10, Section 10.5.3, of Programming with Data has a discussion of blocking and non-blocking connections and how to use them and why that I don't fully understand yet. (and, did MathSoft fully implement this aspect of S?)

Thanks
-Don
--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
--------------------------------------

<Prev in Thread] Current Thread [Next in Thread>
  • scan(): could not skip lines, Don MacQueen <=