Writing a comma delimted text file using CFFILE

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Writing a comma delimted text file using CFFILE

    Can someone please tell me what is the proper syntac for writing a comma
    delimited text file. In the CFSET tag when I name the variable for the output
    attribute of the CFFILE tag I get an error saying this is the wrong syntac.
    Here is my code.


    <cfquery name="Recordset1" datasource="stores">
    SELECT product.ItemNumber, product.Name, product.Summary,
    product.InventoryEnforce, product.InventoryLevel,
    product.InventoryMinimumLevel, product.Weight, product.Units, product.ImageURL,
    product.ThumbnailURL, product.VariationZ, product.Tag, product.ByLine,
    product.MajorT, product.SpecificationX, product.SpecificationY,
    product.Keywords, product.UPC, product.ISBN, product.Remove,
    product.Price_Standard_Orders_USD, product.Sale_Price_Standard_Orders_USD,
    product.Available_Standard_Orders_USD, product.On_Sale_Standard_Orders_USD,
    product.Featured_Standard_Orders_USD, product.Tax_Free_Standard_Orders_USD,
    product.Extra_Shipping_Standard_Orders_USD
    FROM product
    ORDER BY product.ItemNumber, product.Name, product.Summary,
    product.InventoryEnforce, product.InventoryLevel,
    product.InventoryMinimumLevel, product.Weight, product.Units, product.ImageURL,
    product.ThumbnailURL, product.VariationZ, product.Tag, product.ByLine,
    product.MajorT, product.SpecificationX, product.SpecificationY,
    product.Keywords, product.UPC, product.ISBN, product.Remove,
    product.Price_Standard_Orders_USD, product.Sale_Price_Standard_Orders_USD,
    product.Available_Standard_Orders_USD, product.On_Sale_Standard_Orders_USD,
    product.Featured_Standard_Orders_USD, product.Tax_Free_Standard_Orders_USD,
    product.Extra_Shipping_Standard_Orders_USD
    </cfquery>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <cfloop query="Recordset1">
    <!---Error when it is like this--->
    <cfset newProducts = ItemNumber, & "" & Name,>
    <!---No Error when it is like this but there is no comma Below is the first
    line of My Comma delimited Text File--->
    <cfset newProducts = ItemNumber & "" & Name>
    <cffile action="append" file="C:\Documents and
    Settings\Administrator.WBG.000\My Documents\My
    Pictures\ProductStoreImages\commaproduct.txt" output="#newProducts#">
    </cfloop>
    </body>
    </html>

    Item Number,Name,Summary,Inventory Enforce,Inventory Level,Inventory Minimum
    Level,Weight,Units,Image URL,Thumbnail URL,Variation
    #1,Tag,By-Line,Text,Specification #1,Specification
    #2,Keywords,UPC,ISBN,Delete,Price (Standard Orders-USD),Sale Price (Standard
    Orders-USD),Available (Standard Orders-USD),On Sale (Standard
    Orders-USD),Featured (Standard Orders-USD),Tax Free (Standard Orders-USD),Extra
    Shipping (Standard Orders-USD)

    murpg Guest

  2. Similar Questions and Discussions

    1. cffile starts writing on line 2
      I have a .cfm template that builds a .txt file by concatenating strings then writing it to the server using cffile as a text file. The problem is...
    2. Creating a text file & writing to it
      I went through a bit of articles on how to retrieve variables from a .txt file from the local machine. But I want to know can we create a text file...
    3. Writing a Text File in Flash...
      http://www.multidmedia.com/software/flashstudio/features.php is a free (for non-commercial use) app that lets you save to text files.
    4. Writing to a csv text file
      Say I ran a query that pulled 100 records with 10 fields into a RecordSet I'll call "rsQryResult" How would I: 1. write this data to a .csv text...
    5. Loading delimted file into Access with ASP on the fly
      Ed Kautz wrote: As Bob said: don't instantiate an Access object on the server. you can use fso/readline to get a record from the text file. ...
  3. #2

    Default Re: Writing a comma delimted text file using CFFILE

    <cfset newProducts = ItemNumber & "," & Name>

    Or

    <cfset newProducts = "#ItemNumber#, #Name#">

    Ken


    The ScareCrow Guest

  4. #3

    Default Re: Writing a comma delimted text file using CFFILE

    <cfquery name="Recordset1" datasource="stores">
    SELECT product.ItemNumber, product.Name, product.Summary,
    product.InventoryEnforce, product.InventoryLevel,
    product.InventoryMinimumLevel, product.Weight, product.Units, product.ImageURL,
    product.ThumbnailURL, product.VariationZ, product.Tag, product.ByLine,
    product.MajorT, product.SpecificationX, product.SpecificationY,
    product.Keywords, product.UPC, product.ISBN, product.Remove,
    product.Price_Standard_Orders_USD, product.Sale_Price_Standard_Orders_USD,
    product.Available_Standard_Orders_USD, product.On_Sale_Standard_Orders_USD,
    product.Featured_Standard_Orders_USD, product.Tax_Free_Standard_Orders_USD,
    product.Extra_Shipping_Standard_Orders_USD
    FROM product
    ORDER BY product.ItemNumber, product.Name, product.Summary,
    product.InventoryEnforce, product.InventoryLevel,
    product.InventoryMinimumLevel, product.Weight, product.Units, product.ImageURL,
    product.ThumbnailURL, product.VariationZ, product.Tag, product.ByLine,
    product.MajorT, product.SpecificationX, product.SpecificationY,
    product.Keywords, product.UPC, product.ISBN, product.Remove,
    product.Price_Standard_Orders_USD, product.Sale_Price_Standard_Orders_USD,
    product.Available_Standard_Orders_USD, product.On_Sale_Standard_Orders_USD,
    product.Featured_Standard_Orders_USD, product.Tax_Free_Standard_Orders_USD,
    product.Extra_Shipping_Standard_Orders_USD
    </cfquery>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <cfloop query="Recordset1">
    <!---Error when it is like this--->
    <cfset newProducts = ItemNumber, & "" & Name,>
    <!---No Error when it is like this but there is no comma Below is the first
    line of My Comma delimited Text File--->
    <cfset newProducts = ItemNumber & "" & Name>
    <cffile action="append" file="C:\Documents and
    Settings\Administrator.WBG.000\My Documents\My
    Pictures\ProductStoreImages\commaproduct.txt" output="#newProducts#">
    </cfloop>
    </body>
    </html>


    Everything is fine in the above code but <cfoutput> tag is missing because of
    which you might be facing problem. Try this out

    <body>
    <cfoutput>
    <cfloop query="Recordset1">
    <!---Error when it is like
    this--->
    <cfset newProducts =
    ItemNumber, & "" & Name,>
    <!---No Error when it is like
    this but there is no comma Below is the first line of My Comma delimited Text
    File--->
    <cfset newProducts = ItemNumber
    & "" & Name>
    <cffile action="append"
    file="C:\Documents and Settings\Administrator.WBG.000\My Documents\My
    Pictures\ProductStoreImages\commaproduct.txt" output="#newProducts#">
    </cfloop>
    </cfoutput>
    </body>





    harshalsuri Guest

  5. #4

    Default Re: Writing a comma delimted text file using CFFILE

    You do not need to use <CFOUTPUT>. Everything listed is a Coldfusion tag.
    travelinrob Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139