If you're on a Windows platform, I have some CFX tags that may be of help.
Just experimenting, I can alter a 1.3Mb file in under 4 seconds with the
following code.


  <cfx_readLn Filename="C:\Test.txt" Name="ReadLn" Direction="TTB">
  <cfset MyQuery = QueryNew("Line")>
  <cfloop query="ReadLn">
   <cfset QueryAddRow(MyQuery, 1)>
   <cfset QuerySetCell(MyQuery, "Line", ReplaceNoCase(Line, "VFP98", "My new
text", "ALL"))>
  </cfloop>
  <cfx_query2file query="MyQuery" filename="C:\result.txt" NoColumnList>

Paul

  _____  

From: Jim McAtee [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 11 February 2004 19:50
To: CF-Talk
Subject: Re: Help with speeding up a string replace on a large file.

If you don't need the case-insensitivity of ReplaceNoCase(), you might try
ReplaceList() instead.  This will eliminate the loop.  Not sure how much
you'll gain in speed, but letting CF loop over the elements should be faster
than doing it yourself.

----- Original Message -----
From: "Shawn Grover" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, February 10, 2004 4:24 PM
Subject: Help with speeding up a string replace on a large file.

> We have a case where we have 30+ instances of text in an RTF document that
need to be replaced with specific database values.  The routine we have does
work, but it's pretty slow.  In one case, we have a 1+ meg file, that we
need
to do the 30 replacements on via the REPLACENOCASE function.  This file is
taking approx 3-5 minutes to open.  We've explored using REREPLACE instead,
but are not seeing any noticable speed improvement.
>
> The algorithm we have is something like so:
>
> 1. read file into a memory variable via the CFFile tag with action=""> > 2. Loop through our elements to replace
> 3.    do an replace on the file in memory for the current element
> 4. End loop
> 5. Write the new file out to a temporary file (which we manage through
another process).
>
> We've used the GetTickCount function to narrow down exactly where the
delay
is, and it's in the loop - not on the read and write commands.
>
> I'm sure there's a better way to do this - we're looking for a sub 10
second response time, if possible.  Any suggestions?
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to