Gary Williams
02-13-2008, 08:08 PM
Hi All,
I have a large postcode file that needs modfying. It came as a csv file (36MB) which I imported into MySQL, giving a total of 1,762,919 records. I worked out the changes (8 in total) I need to make and using a 5 record sample, checked the asp script I wrote produced the correct changes.
My problem is this. To process this database table on my local PC using IIS takes many hours and times out before completion. I tried using SQLyog but the code that works in asp does not work in the query window of SQLyog.
How do I process this table to get my final result?
The code that works is as follows. Each 'execute' line deals with one of the 8 changes change. The rem'ed out html is just to show the results for an initial loop of 5 records.
Regards
Gary
===============================
<html>
<body>
<%
Dim ocn,ors,strConnection,strSQL
set ocn = Server.CreateObject("ADODB.Connection")
set ors = CreateObject("ADODB.Recordset")
strConnection = "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;"
strConnection = strConnection & "pwd=;database=postcodes;Option=3;"
ocn.open strConnection
strSQL = "SELECT * FROM currentpostcodes ORDER BY recordid ASC;"
ors.open strSQL, ocn
%>
<table border="1" width="100%">
<tr>
<%
'for each x in ors.Fields
'response.write("<th>" & x.name & "</th>")
'next
%>
</tr>
<%
a = 1
ors.movefirst
' Do until a = 5
Do until ors.eof
%>
<tr>
<% 'for each x in ors.Fields%>
<td><% 'Response.Write(x.value)%></td>
<% ' next %>
</tr>
<%
var1 = ors("postcode1")
var2 = ors("postcode2")
var3 = var1+var2
var4 = left(ors("ratingdata"),1)
var5 = mid(ors("ratingdata"),2,1)
var6 = right(ors("ratingdata"),1)
bac = (asc(""&var4&"")-64)
ocn.Execute ("UPDATE current SET CompanyNumber = '1' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET AreaLoad = 'N' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET FloodArea = 'N' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET Postcode = '" & var3 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET ContentsAreaCode = '" & var4 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET SubsidenceRate = '" & var5 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET FloodRate = '" & var6 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET BuildingsAreaCode = '" & bac & "' WHERE recordid = " & a & "")
a=a+1
ors.movenext
loop
ors.close
ocn.close
%>
</table>
</body>
</html>
=========================
I have a large postcode file that needs modfying. It came as a csv file (36MB) which I imported into MySQL, giving a total of 1,762,919 records. I worked out the changes (8 in total) I need to make and using a 5 record sample, checked the asp script I wrote produced the correct changes.
My problem is this. To process this database table on my local PC using IIS takes many hours and times out before completion. I tried using SQLyog but the code that works in asp does not work in the query window of SQLyog.
How do I process this table to get my final result?
The code that works is as follows. Each 'execute' line deals with one of the 8 changes change. The rem'ed out html is just to show the results for an initial loop of 5 records.
Regards
Gary
===============================
<html>
<body>
<%
Dim ocn,ors,strConnection,strSQL
set ocn = Server.CreateObject("ADODB.Connection")
set ors = CreateObject("ADODB.Recordset")
strConnection = "driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;"
strConnection = strConnection & "pwd=;database=postcodes;Option=3;"
ocn.open strConnection
strSQL = "SELECT * FROM currentpostcodes ORDER BY recordid ASC;"
ors.open strSQL, ocn
%>
<table border="1" width="100%">
<tr>
<%
'for each x in ors.Fields
'response.write("<th>" & x.name & "</th>")
'next
%>
</tr>
<%
a = 1
ors.movefirst
' Do until a = 5
Do until ors.eof
%>
<tr>
<% 'for each x in ors.Fields%>
<td><% 'Response.Write(x.value)%></td>
<% ' next %>
</tr>
<%
var1 = ors("postcode1")
var2 = ors("postcode2")
var3 = var1+var2
var4 = left(ors("ratingdata"),1)
var5 = mid(ors("ratingdata"),2,1)
var6 = right(ors("ratingdata"),1)
bac = (asc(""&var4&"")-64)
ocn.Execute ("UPDATE current SET CompanyNumber = '1' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET AreaLoad = 'N' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET FloodArea = 'N' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET Postcode = '" & var3 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET ContentsAreaCode = '" & var4 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET SubsidenceRate = '" & var5 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET FloodRate = '" & var6 & "' WHERE recordid = " & a & "")
ocn.Execute ("UPDATE current SET BuildingsAreaCode = '" & bac & "' WHERE recordid = " & a & "")
a=a+1
ors.movenext
loop
ors.close
ocn.close
%>
</table>
</body>
</html>
=========================