I am teaching myself CF Development and am using a shared CF Hosted Site for testing as I learn.
I have a spreadsheet containing 2500 plus records of data, in about 15 columns. The spreadsheet contains data critical to the basis of this application. It is maintained offline and periodically uploaded to the server using cffile
. After the upload, the spreadsheet is imported into a MySQL table, line by line.
The problem is it's taking entirely too long. For example, it is currently running now. In the last 43 minutes, only 192 of 2500 records have been added to the MySQL table. Is there a more efficient way to do this?
If you review the code below, inside the cfloop
it runs the cfspreadsheet tag, and retrieves the current line. Then adds that line as "CSV" data to the MySQL table.
Any suggestions on how to do this more efficiently?
<cfloop index="RecordNumber" from="2" to="#Records#" step="1">
<cfspreadsheet action="read"
format="csv"
name="siteinfo"
src="#floc#"
headerrow="1"
rows="#RecordNumber#"
columns="1-7,15,16,22,23"
>
<cfset ColumnCount = ListLen(siteinfo)>
<cfset CSVSiteData = #siteinfo#>
<cfset EntryType = "Site_Data">
<cfquery name="Insertsite" datasource="TechData">
INSERT INTO sitelist (EntryType, CSVSiteData, DateInserted)
VALUES ('#EntryType#', '#CSVSiteDataf#', '#DateInserted#')
</cfquery>
</cfloop>