Ahh I see that looks fairly straight forward. I thought about writing a
vb.net app but it seems overkill to cfexecute a .exe to read just the top
line of a file.

Jeremy

-----Original Message-----
From: Joe Rinehart [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 03, 2004 10:38 AM
To: CF-Talk
Subject: Re: <cffile read> to read JUST the top line of the txt file.

Yep - this should get you started:

<cfscript>
   filename = "/path/to/file.csv";
   fileReader = createObject("java", "java.io.FileReader");
   fileReader = fileReader.init(filename);
   lineReader = createObject("java","java.io.LineNumberReader");
   lineReader = lineReader.init(fileReader);

   line = lineReader.readLine();

   /* this'd keep reading in lines
   while (isDefined("line")) {
     lineCount = lineCount + 1;

     // do something here with the data in variable line

     line = lineReader.readLine();
   }
   */
</cfscript>

<cfoutput>#line#</cfoutput>

-joe

On Fri, 3 Dec 2004 15:55:01 +0100, Pascal Peters <[EMAIL PROTECTED]> wrote:
> No, but I think you can do it with java.
> 
> 
> 
> > -----Original Message-----
> > From: Jeremy Bunton [mailto:[EMAIL PROTECTED]
> > Sent: 03 December 2004 15:52
> > To: CF-Talk
> > Subject: <cffile read> to read JUST the top line of the txt file.
> >
> > Hello,
> >
> > I want to use <cffile> to read just the top line (header line with
> field
> > names) of a very large .csv file, say 5 million records. Is there a
> way to
> > just read the top record into the variable in the cffile tag, with out
> > having to read the whole file.
> >
> > Jeremy
> >
> >
> >
> >
> >
> >
> >
> 
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186088
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to