Using the list function with CSV files can be an issue since the List stuff in CF doesn't recognize a blank column. So Something,,, only returns 1 element.
The other thing is that excel does weird things with CSV files also. There is a really nice java library called Ostermiller http://ostermiller.org/utils/ExcelCSV.html That has a great CSV reader that I have had no trouble getting it to properly parse any CSV you throw at it. J.J. On 8/24/07, Steve Sequenzia <[EMAIL PROTECTED]> wrote: > 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, ',')#' > #listgetat('#record#',7, ',')#' > #listgetat('#record#',8, ',')#' > #listgetat('#record#',9, ',')#' > #listgetat('#record#',10, ',')#' > #listgetat('#record#',11, ',')#' > #listgetat('#record#',12, ',')#' > #listgetat('#record#',13, ',')#' > ) > > </cfquery> > > </cfloop> > > Any help with this would be great. > > Thanks. > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:287086 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4