![]() ![]() ![]() |
Using the CFHTTP Get operation, you can create a query object from a delimited text file. This is a powerful means for processing and handling generated text files. Once the query object is created, it is very simple to reference columns in the query and perform other ColdFusion magic on the data.
Text files are processed in the following manner:
In this example, a query object is created from a comma-delimited text file. The CFOUTPUT tag is used to output specific columns in the query. The text file consists of six columns, separated by commas. The first row of the file looks like this:
OrderID,OrderNum,OrderDate,ShipDate,ShipName,ShipAddress
This example accepts the first row of the text file as the column names:
<CFHTTP METHOD="Get" URL="http://127.0.0.1/orders/june/orders.txt" NAME="juneorders" DELIMITER="," TEXTQUALIFIER=""""> <CFOUTPUT QUERY="juneorders"> OrderID: #OrderID#<BR> Order Number: #OrderNum#<BR> Order Date: #OrderDate#<BR> </CFOUTPUT>
You can substitute different column names by using the COLUMNS attribute:
<CFHTTP METHOD="Get" URL="http://127.0.0.1/orders/june/orders.txt" NAME="juneorders" COLUMNS="ID, Number,Date" DELIMITER="," TEXTQUALIFIER=""""> <CFOUTPUT QUERY="juneorders"> Order ID: #ID#<BR> Order Number: #Number#<BR> Order Date: #Date#<BR> </CFOUTPUT>
![]() ![]() ![]() |
AllaireDoc@allaire.com
Copyright © 1998, Allaire Corporation. All rights reserved.