Your main problem is your csv file - here a demo:
01042011;09:39:24;2944;3409;3923
[CR][LF]
[CR]
01042011;09:39:24;4915;3909;3923
[CR][LF]
[CR]
....
Only each third line was used for data, so you have to check for line.Length!
Here my results:
Sub InsertInList
Dim textrd As TextReader
textrd.Initialize(File.OpenInput("K:\ticks","ticks.csv)
Dim line As String
Dim List1 As List
List1.Initialize
Log (DateTime.Time(DateTime.Now))
line = textrd.ReadLine
Dim counter As Int = 0
Do While line <> Null
If line.Length>5 Then 'only each third line has really data - thats why regex didnt work..
Dim m1() As String
m1=Regex.Split(";",line)
m1(0) = m1(0).SubString(4) & m1(0).SubString2(0,4)
List1.Add(m1)
counter = counter + 1
End If
line = textrd.ReadLine
Loop
Log (DateTime.Time(DateTime.Now))
Log (counter)
End Sub
Time needed for filling 4.178.888 records to list: 13 seconds, i could not see any memory problems, next step was to repeat it two times,
there was no memory problem with now more then 12 million records in the list; time needed: 21 seconds.
my new variant of converttodb
Sub converttodb
Dim textrd As TextReader
textrd.Initialize(File.OpenInput("Z:\","ticks.csv"))
Dim line As String
Log (DateTime.Time(DateTime.Now))
line = textrd.ReadLine
If File.Exists("Z:\ticks","b4jticks.db") Then File.Delete ("Z:\ticks","b4jticks.db")
Dim counter As Int = 0
Dim C2 As Int =0
SQL.ExecNonQuery("CREATE TABLE table1 (Date TEXT , Time TEXT, Price TEXT, Bid TEXT, Ask Text)")
Do While line <> Null
If line.Length>5 Then
Dim m1() As String
m1=Regex.Split(";",line)
m1(0) = m1(0).SubString(4) & m1(0).SubString2(0,4)
counter = counter + 1
C2=C2+1
SQL.AddNonQueryToBatch("INSERT INTO table1 VALUES (?,?,?,?,?)", m1)
End If
If C2=1000000 Then
Dim SenderFilter As Object = SQL.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
C2=0
Log(counter)
End If
line = textrd.ReadLine
Loop
Dim SenderFilter As Object = SQL.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log (DateTime.Time(DateTime.Now))
Log (counter)
SQL.Close
End Sub
I used for the first time addnonQuerytoBatch with Wait for...
In release mode it was ready in 47 seconds, the file size is 186.981 kb
Every 1 million records i used SQL.ExecNonQueryBatch, and there was no real time difference if i used it every 100.000 records.
Only when i tried to insert all records at once java had problems, used my cpu to 99% for minutes, but didnt crash! But the time was four times higher than usual.
I tried to simplify as much as possible and integrated the parsing and removed the use of maps.
So i hope i could clear the problem.
P.S: My son used c++ to read the file in array: 5 sec against 13 sec. in java.