Reputation: 125
I am trying to parse apache access.log files in VB delimited by space, however one of the fields is enclosed by "" I have tried
Using ioReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(foundFile)
ioReader.TextFieldType = FileIO.FieldType.Delimited
ioReader.SetDelimiters(" ") ioReader.HasFieldsEnclosedInQuotes = True
Dim currentRow As String()
While Not ioReader.EndOfData
End While
End Using
However I receive the error: Line 1 cannot be parsed using the current Delimiters. If I change HasFieldsEnclosedInQuotes = False, then my data is malformed
an example line i want to read is:
192.168.0.1 - - [17/Nov/2014:03:34:29 +0000] "GET /bluebell.html HTTP/1.1 "200 13675 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" "-"[RT:0.769] [C:1115486]
Upvotes: 1
Views: 459
Reputation: 15813
There are a couple of ways to handle this. One way is use Try/Catch to ignore or repair any lines with improper formats. Another way is to read each line as a string and parse it yourself in the program using regex or string manipulation.
Upvotes: 1