Hows it going everyone. Im still pretty new to vb .net, and am having a little trouble. I am loading a tab delimited txt file into an access database, and parsing the text to extract some of the needed information from each field, and while this works, it is really slow right now. Does anyone have any suggestions on how I could speed this up? The file that Im trying to load atm has about 100k rows.
Code:
Dim fs As New IO.FileStream(openFileDialog1.FileName, IO.FileMode.Open) Dim sr As New IO.StreamReader(fs) Dim x() As String = sr.ReadToEnd().Split(CType(Chr(10), Char)) Dim docno() As String Dim doc As String Dim file As String Dim fileloc As Integer While J < x.Length - 1 docno = x(J).Split(vbTab) 'MsgBox(docno(4)) ' If myRegex.IsMatch(x(J)) = True Then If docno(2).Contains("\") = True Then fileloc = docno(2).LastIndexOf(CType("\", Char)) Else fileloc = 0 End If file = docno(2).Substring(fileloc) While file.Contains(Chr(34)) = True file = file.Remove(file.IndexOf(Chr(34)), 1) End While While file.Contains("\") = True file = file.Remove(file.IndexOf("\"), 1) End While ' x(J) = myRegex.Match(x(J)).Value doc = docno(3) While doc.Contains(Chr(34)) = True doc = doc.Remove(doc.IndexOf(Chr(34)), 1) End While Table1TableAdapter.Insert(doc, file, "Member of Txt", "0") Table1TableAdapter.Update(TestdbDataSet.Table1) ' End If J = J + 1 End While
Comment