March 11th, 2004, 09:10 AM
Need advice about CFFile
I am tasked with pulling a text file into a CF program. I am assuming CFFILE is the best method for doing this. But this file contains many rows of records. It pulls in the data so far, but it comes in as one huge chunk of data. What I need to do is be able to separate those rows and perform actions with individual fields in those rows such as summarizations.
Due to a time constraint any help would be appreciated. Thanks.
March 11th, 2004, 09:27 AM
Assuming each line ends with a carriage return and line feed, just treat the text as a list with a delimiter of carraige return and line feed. Now you can loop over the list and each list element will be one row of the text file.
March 11th, 2004, 09:40 AM
Wow! That was a quick response. Could you provide some pseudo code or some example code? Thanks.
Last edited by dt2003; March 11th, 2004 at 10:00 AM.
March 11th, 2004, 02:31 PM
<cffile action="READ" file="#expandPath( someFile )#" variable="textFile">
<cfloop index="thisRow" list="#TextFile#" delimiters="#chr(13)##chr(10)#">
...do whatever you need to do on each row...
March 11th, 2004, 03:37 PM
Thanks. I am not sure I understand the use of "#chr(13)##chr(10)#" as a delimiter. Can use please explain? Thanks.
Originally Posted by kiteless
March 11th, 2004, 04:46 PM
It's the ascii characters for a carriage return and a line feed, and is how most text documents denote the end of a line and the start of a new one.