Actually, that's pretty well thought-out by returning the position where you
ended your last read.  Lots of file open/closes, but at least you don't have
to scan the file each time to find your line.  Is it possible to create a
CFX that leaves the file open and passes back a file handle, allowing
subsequent tag calls to use the file handle as a parameter?  Needless to
say, this would be dangerous, but I assume that the proper use of CF error
trapping would catch fatal errors, allowing you to close the file and
preventing you from leaving files open all over the place.

Jim


----- Original Message -----
From: "Lewis Sellers" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, January 24, 2002 7:59 PM
Subject: Re: extracting data from a huge text file


> On Thu, 24 Jan 2002 18:10:10 -0700, "Jim McAtee"
> <[EMAIL PROTECTED]> wrote:
>
> >How does it accomplish this when you want to loop over the contents of a
> >large file?  Does it keep the file open, or when you call it to read the
> >250,000th line, has it opened and closed and read through the file
249,999
> >times already?
> >
> >Jim
>
> Nothing complicated involved. Every time you call the tag it opens the
> file and reads in the next carriage-deliminated string. Then closes
> the file.
>
> *You* pass to it the position in the file you want to read the next
> line from. "0" is the beginning of a file.
>
> Of course to make your life easy, it returns the position in the file
> the next line starts at. :) Just use the number in the next call while
> looping... or save it somewhere for later.
>
> With all that file opening, I'm not saying it's fast -- but it's
> simple and gets the job done.
>
> As for your example, if you happen to already know (or can guess --
> say all lines are a fixed width) you can go directly to it. Otherwie,
> yes, you would have to parse through all the previous lines to know
> what the position of the line is in the file.
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to