#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    3
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    3
    Rep Power
    0
    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 09:00 AM.
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    <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...
    </cfloop>
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    3
    Rep Power
    0
    Originally Posted by kiteless
    <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...
    </cfloop>
    Thanks. I am not sure I understand the use of "#chr(13)##chr(10)#" as a delimiter. Can use please explain? Thanks.
  10. #6
  11. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    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.

IMN logo majestic logo threadwatch logo seochat tools logo