macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

comma Delimited file

Subject: comma Delimited file
From: "fyrehed"
Date: Tue, 7 Aug 2007 15:53:34 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
Hello,

 I have a need to insert a csv file into a table.  I am having a problem with 
the insert query, three of the 132 fields commonly have commas in the text 
within the field and making the query barf.  Please help.

 Matt

 <cffile action="read" file="\\my\complete\path\info\data.csv" 
variable="datacsv">


 <cfloop index="index" list="#datacsv#"  delimiters="#chr(10)##chr(13)#">
  
        <cfquery datasource="#application.ds#" timeout="180">
                Insert INTO myTable(all, my, field, names)
                                Values
                                ('#listgetAt(index,1, ',')#', 
'#listgetAt(index,2, ',')#',' 
#listgetAt(index,3, ',')#','#listgetAt(index,4, ',')#')
        </cfquery>

 </cfloop>


<Prev in Thread] Current Thread [Next in Thread>