I actually used SQL to do it because I was having issues with the CFM code. I still need to come up with a way for end users to do it from a web page. I need to look into it some more.
> 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, ',')#' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get involved in the latest ColdFusion discussions, product development sharing, and articles on the Adobe Labs wiki. http://labs/adobe.com/wiki/index.php/ColdFusion_8 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:287237 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4