Ok, then that is a bit different. The following is based off the these
assumptions (hopefully I won't make an ass out of u and mption..oh I kill
me)...


Each line ends with a VBCRLF
Each row is comma delimited.


** You may need to check the above two in your file and replace the correct
escape codes in the following example:


SAMPLE METHOD 1 ::
<!--- This will loop through the entire file line by line --->
<cfloop list="#cfhttp.fileContents#" index="line"
delimiters="#chr(10)##chr(13)#">


<!--- Once you are in the first row you need to then loop through the
columns --->
<cfloop index = "index_name" List = "#line#" delimiters = ",">


<!--- Ok , at this point you now have row 1 in an indexed loop that you can
cycle through --->
<!--- based on your sample data this will loop 5 times for each row, one for
each column --->
<!--- you simply need to output the first and last instance of this loop and
you will get Code and Price --->


</cfloop>
</cfloop>

SAMPLE METHOD 2::


Another way would be the following::


<cfset sLogpath = "c:\ errorlog.txt">
<!--- init line counter --->
<cfset countLines = "0">
<!--- init error counter --->
<cfset countErrors = "0">


<cfloop list="#fileContents#" index="line" delimiters="#chr(10)##chr(13)#">
    <!--- trim spaces off beginning and end of line --->
    <cfset line = trim(line)>
    <!--- if line is not blank --->
    <cfif len(line)>
            <cfif listLen(line,",") eq 9>
                        <cfset Code = ListGetAt(line,1 ,",")>
                        <cfset Price = ListGetAt(line,5 ,",")>
                        <!--- increment line counter --->
                        
<!--- Output #Code# and #Price# here --->
<cfoutput>
#Code# - #Price# <br>
                        </cfoutput>                    


                        <cfset countLines = countLines + 1>
            <cfelse>
                        <!--- Write Error Log --->
                        <cffile action="" file="#sLogpath#"
output="[Line Skipped - #listLen(line,',')# Columns] #line#"
addnewline="yes">
                        <cfset countErrors = countErrors + 1>
        
</cfif>   
</cfif>
</cfloop>


<!--- display results --->
<cfoutput>
            <font face="Arial" size="2">
    <b>File Parsing Results</b>
    <hr>
    Lines processes correctly : <font color="green">#countLines#</font><p>
    Lines skipped due to errors : <font color="red">#countErrors#</font><p>
    Errors logged to : #sLogpath#<p>
            </font>
</cfoutput>


-----Original Message-----
From: Jim T [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 11:11 AM
To: CF-Talk
Subject: RE: Query of a text file


But I only want to output code and price
  -----Original Message-----
  From: Schuster, Steven [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 09, 2003 9:09 AM
  To: CF-Talk
  Subject: RE: Query of a text file

  Well....
  First of all use this #cfhttp.filecontent# to see what is in the file.

  If you need to loop through those contents you will have to do something
  like this:

  <cfloop list="# cfhttp .fileContents#" index="line"
  delimiters="#chr(10)##chr(13)#">

  This assumes this is a list separated and users vbcrlf for line ends. You
  can play around with it if need be.

  Inside the cfloop just output #line# to see the contents of the current
row.

  You could also assign values or store in a DB at that point as well..

  Steve

  -----Original Message-----
  From: Jim T [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 09, 2003 10:55 AM
  To: CF-Talk
  Subject: Query of a text file

  I am Stuck .. can someone help?

  I am getting this error:

        Attribute validation error for tag cfoutput.
        The value of the attribute query, which is currently "thefile", is
  invalid.

  this is the text filetop of the text file:
  Code,page,title,unit,price
  884,248,LIGHTED ROSE BASKET,1 EA,9.95
  1402,194,3 PC BRASS BUTTERFLY WALL SET,1 SET,6.30
  1506,91,BRASS/SHIPS CARGO LANTERN,1 EA,53.30
  1875,175,10 PC PORC COBALT BLUE TEA SET,1 SET,3.65
  1932,54,"CHILDREN'S PLAQUE",1 EA,2.65
  2018,303,100 BR/BELL WIND CHM,1 EA,2.95

  This is the code:

  <!--- Get the file --->
  <cfhttp url="">           method="GET"
          Name="thefile">
  </cfhttp>
  <!--- Output the file --->
  <cfoutput query="thefile">
  code<b>#code#</b>
  </cfoutput>
  Are you paying more than $9.99 for internet? Then you are paying too much!
  http://bizovation.speedydialup.net <http://bizovation.speedydialup.net>
<http://bizovation.speedydialup.net>
    _____
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to