> I have huge 3-5GB flat data files that need to be imported into a
> database.
> I know CF5 had no way to read files a line at a time and we had to write
> a VB prob to do that.
> Does CFMX have a way to read files in a line at a time rather than loa
> dthe whole file into a variable ?
 -- I'd suggest that you shouldn't consider ColdFusion to read in a 3-5GB
flat data file, even if ColdFusion can read files a line at a time.
ColdFusion could probably handle it, but using CF would be like using a
screwdriver to hammer in a nail.

In Java, you could easily write something like this:

String line = null;
FileReader fr = new FileReader(filename);
BufferedReader bf = new BufferedReader(fr, 8192);
try {
        while ((line = bf.readLine()) != null) {
                // do stuff w/ the lin
        }
        bf.close();

} catch (IOException io) {
        System.out.println("IOException: " + io.toString());
}

and that can be migrated to CF like this:

<cfscript>

fileAsString = "";
filePath = "c:\folder\yourBigAssFile.txt";
fileReader = CreateObject("java", "java.io.FileReader");
fileReader.init(filePath);
br = CreateObject("java", "java.io.BufferedReader");
br.init(fileReader);
try {
   do {
        fileAsString = br.readLine();
        WriteOutput(fileAsString & chr(10) & chr(13));
   } while (true);
} catch (coldfusion.runtime.UndefinedVariableException e) {
          // this indicates end of file, ok to ignore error
}
</cfscript>


I'd suggest you look at doing this using Java OR using BCP (assuming that
you're using SQL Server: http://techrepublic.com.com/5100-6268-1052274.html)

Aaron Johnson
[EMAIL PROTECTED]
http://cephas.net/blog/



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to