Why not use dts?  Put the work on the db server, not the cf server.  MUCH 
faster too.

-----Original Message-----
From: "Steve Sequenzia" <[EMAIL PROTECTED]>
To: "CF-Talk" <cf-talk@houseoffusion.com>
Sent: 8/24/07 2:32 PM
Subject: Importing CSV into

I am trying to write some code that takes a .csv file and inserts it into SQL.

I am having issues with it reading the header. I would like to be able to leave 
the header on the file and not have it insert the header data into the DB.

When I try to run it without a header I am having issues with it reading the 
number of elements wrong. It is getting confused when a line has blank data for 
the element.

So it see following line as only having 8 elements when it should have 13:

,Zachary,Abbott,D.O.,,1720 Northbrook Drive,,Ann Arbor,MI,48103,[EMAIL 
PROTECTED],,

Here is my code:

<cffile action="read" file="#file1#" variable="fileData">

<cfloop list="#fileData#" delimiters="#Chr(10)##Chr(13)#" index="record">

<cfquery name="qryInsert" datasource="physleads">

INSERT INTO contacts (prefix, firstName, lastName, suffix, companyName, 
address, address2, city, state, zipCode, phone, fax, email)
values (
 #listgetat('#record#',1, ',')#'
 #listgetat('#record#',2, ',')#'
 #listgetat('#record#',3, ',')#'
 #listgetat('#record#',4, ',')#'
 #listgetat('#record#',5, ',')#'
 #listgetat('#record#',6, ',')#'


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:287069
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to