3 Replies Latest reply on Jun 7, 2006 1:59 AM by kabbi~thkek

    Problem importing text file with null value

    ulin9je Level 1
      I used the following codes to import a text file and it worked perfectly.
      However, it skipped the TAB (chr(9)) on the imported row when there is no data (empty string) in one of the columns.
      Can someone help? thanks!

      sample text file data:
      00001 desc1 12.00
      00002 25.00
      00003 desc2 15.00

      Code that I used:
      <cffile action="read" file="#FilePath#" variable="data">
      <cfset newLine = chr(13) & chr(10)>
      <cfset tabChar = chr(9)>

      <cfoutput>
      <cfloop list="#data#" index="row" delimiters="#newLine#">
      <cfset cols = listToArray(row, tabChar)>

      ID = #cols[1]#
      desc = #cols[2]#
      price = #cols[3]# <br>
      </cfloop>
      </cfoutput>