Thanks Sima, 
Thats some pretty cool functionality.  Thanks again for debugging it.  I'll
look forward to using it.

DRE

-----Original Message-----
From: Sima Lee [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 28, 2002 9:48 AM
To: CF-Talk
Subject: RE: extracting data from a huge text file (my update on it)


Hi Chris and Andre,

Now I made this java class code works on both CF4.5 and CF5.0. 

On both version the class file is OK, nothing needs to be changed.
 
But changes should be made on the JavaFileTest.cfm , the sample test
file.

For it to work on CF4.5 just take out the <cfflush> tag in the
javafileTest.cfm (Does it come with CF5.0?). 

But for it to work on CF5.0 we need to add two extra lines.

In the original javafileTest.cfm , a FileReader to be initiated by
calling the constructor with a String   
object: the file name. But CF5.0 does not accept it. Instead I create a
file object first and pass the file object into FileReader constructor
instead of the String object . Then it works just fine. 

So after  the first line <cfset fn = cgi.cf_template_path> I add:

<!--- create a file object --->
<cfobject type="Java" class="java.io.File" name="myfile"
action="create">
<!--- call the constructor of the file object pass a string to it --->
<cfset myfile.init(fn)>
Then after the this line:
<!--- create a Java FileReader object to read this file --->
<cfobject type="Java" class="java.io.FileReader" name="fr"
action="create">
you pass the file object to the FileReader constructor:
<!--- call the constructor of the FileReader by passing a file object"
--->
  <cfset fr.init(myfile)>  

Since the test file is very short I will just copy and past the whole
file here.

JavaFileTest.cfm starts here:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
        <title>Untitled</title>
</head>

<body>

<!--- get our filename from the CGI environment or you can set any file
you want to be read from--->
<cfset fn = cgi.cf_template_path>

<!--- create a file object --->
<!--- note that java.io.File is a native Java class.--->
<cfobject type="Java" class="java.io.File" name="myfile"
action="create">

<!--- call the constructor of the file object pass a string to it --->
<cfset myfile.init(fn)>

<!--- create a Java FileReader object to read this file --->
<!--- note that java.io.FileReader is a native Java class.--->
<cfobject type="Java" class="java.io.FileReader" name="fr"
action="create">

<!--- call the constructor of the FileReader by passing our file object"
--->
  <cfset fr.init(myfile)> 
   
<!--- now pass the FileReader object to our extended BufferedReader --->
<cfobject type="Java" class="CFBufferedReader" name="reader"
action="create">
<cfset reader.init(fr)>
<!--- read the first line from the file --->
<cfset curLine=reader.readLine()>
<!--- now loop until we reach the end of the file --->
 <cfloop condition="not #reader.isEOF()#">
        <!--- display the current line --->     
        <cfoutput>#replace(curLine,"<","&lt;","ALL")#<br>
        </cfoutput>     
        <!--- flush the output buffer (cf5 only) --->   
        <cfflush>       
        <!--- each call to readLine( ) reads the /next/ line,
          until the end of the file is reached, at which point
      isEOF( ) starts returning "true" --->     
        <cfset curLine=reader.readLine()>
</cfloop> 



</body>
</html>

JavaFileTest.cfm ends here.
Hope this update helps

Regards,


Sima



-----Original Message-----
From: Andre Turrettini [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 3:12 PM
To: CF-Talk
Subject: RE: extracting data from a huge text file


Chris, Sima,  Can you keep me posted on what you figure out with that 
java
io buisness. I'll have to do something similar soon myself.  And it 
will
probably give a bit of a headsup on NEO.  Thanks.  DRE

[EMAIL PROTECTED]

-----Original Message-----
From: Sima Lee [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 11:24 AM
To: CF-Talk
Subject: RE: extracting data from a huge text file


Hi, I have had it complied but have not try it out yet. If you want
please contact me off list, because I cannot attach any file here. 

Regards,

Sima

-----Original Message-----
From: Chris Giminez [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 12:54 PM
To: CF-Talk
Subject: Re: extracting data from a huge text file


It does look ideal. Unfortunately, I'm not sure how to plug in and
compile the Java code and don't
know that I can take the time to learn just now.
Anyone have the class files for this that can be plugged in ready to
roll?

Chris


> This should be IDEAL for you.
> 
http://www.macromedia.com/v1/handlers/index.cfm?ID=22277&method=full

>
> DRE
>
> -----Original Message-----
> From: Jim McAtee [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 24, 2002 6:10 PM
> To: CF-Talk
> Subject: Re: extracting data from a huge text file
>
>
> 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
>
>
> ----- Original Message -----
> From: "Lewis Sellers" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Thursday, January 24, 2002 5:54 PM
> Subject: Re: extracting data from a huge text file
>
>
> > On Thu, 24 Jan 2002 16:09:54 -0800, "Chris Giminez"
> > <[EMAIL PROTECTED]> wrote:
> >
> > >I'm trying to retrieve data and put it into a database from a text
> file.
> > >The text file is over 100MB with  (I'm guessing) around 260,000
> records,
> each record contains 85
> > >fields.
> > >
> > >I tried to create a conditional loop at each line break, which
works
> fine
> if I am working on a
> > >smaller version of the file, but chokes on the 100MB monster. Is
> there a
> more efficient way to deal
> > >with this other than looping through it or is there a way to break
> this
> file up into smaller chunks
> > >and deal with it piece by piece?
> >
> >
> > Been a while since I used it but I wrote a cfx called... hmm.. I
> don't
> > recall what it was called /-) ... anyway, the cfx was to read in 
log
> > files one line at a time.
> >
> > Which is what it does, one carriage-deliminated line per call, not
> the
> > entire file all at once.
> >
> > It's somewhere at http://www.intrafoundation.com/freeware.html.
> >
> > --min
> >
>
> 




______________________________________________________________________
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