CF8 - I'm using cfloop to read a file, as described in the documentation:
<cfloop
index = "index name"
file = "absolute path and filename">
</cfloop>
It's a text file; is there a way to define lines? Like start reading at line
4000?
Thanks if anyone knows!
phamm - 28 Aug 2008 21:46 GMT
I think I found the answer here.
http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html
Dan Bracuk - 29 Aug 2008 00:50 GMT
I didn't read your link, but my method would be to treat the file as a list separated by chr(10) & chr(13).
-==cfSearching==- - 29 Aug 2008 01:16 GMT
Both techniques would work. I have not done much work with the new file
objects. But the difference seems to be whether the entire file is read into
memory at once or only portions of it. For large files, the technique in the
blog entry would be a better fit. Because it works with smaller chunks of
information. I do not know if it makes a difference with smaller files.
From: http://coldfused.blogspot.com/2007/07/new-file-io-in-coldfusion-8.html
[i]With cfloop, you can also iterate over a part of the file by specifying
"from" and "to" values. Here is an example to loop over lines between 10 and
20.[/i]
<cfloop file="c:\temp\myfile.txt" index="line" from=10 to=20>
<cfoutput>#line#</cfoutput> <!--- or do whatever with the line --->
</cfloop>
phamm - 29 Aug 2008 13:39 GMT
Since I am dealing with large files (500K+lines), I'm going to use the "from="
option. It's frustrating that this option is not in the Cold Fusion 8 "cfloop"
documentation, particularly since better file handling in cfloop is one of the
major new features in cf8! I wonder how many other undocumented features are
out there for cold fusion? Is this the tip of the iceberg?