Sorry I have been lazy about posts recently. I’ve been in Boston, meeting with various product teams. All I can say is that there is some cool stuff on the horizon.
Anyway, did you know that CFHTTP can automatically turn a comma-delimited file into a query object for you? Let’s say you have a file called data.txt that looks like this:
firstName, lastName, emailAddress Christian, Cantrell, email@example.com Mike, Chambers, firstname.lastname@example.org Baby, Blue, email@example.com
The following use of CFHTTP will parse the data above into a query stored in the variable “myQuery”:
<cfhttp method="GET" url="http://localhost/tests/cfhttp/data.txt" name="myQuery">
You can use the
columns attribute of the CFHTTP tag to specify a different set of column headers, and you can use the
firstrowasheaders attribute to include the first row as data rather than column headers. And, of course, your comma-delimited file doesn’t have to be static; the delimited values can be dynamically generated by any means.