bakershawnm
Programmer
hello all,
I am using TextFieldParser to parse through a text file looking for small snippets of information. Large file, lots of useless data. But it has the advantage that since it is intended to be a printed file it has unique delimiters (vertical bar) for columns and page edges. Makes using the TextFieldParser very easy.
Well the problem is in some of the useless information I could have a comment that ends with a ". instead of the ." like it should. TextFieldParser then throws a MalformedLineException and causes my program to halt processing of the file and continue on to push the data it has into the database.
I really don't care about the data on any lines that would have that on them so what I am looking for is what is the best way to skip reading that line and continue on with the file?
I catch the exception (see below) and thought about changing the delimiter to nothing and setting it to not delimited and reading the line then setting it back to delimited. However not sure that would be the best way or if it would even work (since I have not tired it yet).
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox(ex.Message & " - Malformed line exception.")
MSDN documentation is sorely lacking (as usual) on these kinds of things and I have not been able to find anything else on the subject.
Any help is (as always) appreciated.
shawn
I am using TextFieldParser to parse through a text file looking for small snippets of information. Large file, lots of useless data. But it has the advantage that since it is intended to be a printed file it has unique delimiters (vertical bar) for columns and page edges. Makes using the TextFieldParser very easy.
Well the problem is in some of the useless information I could have a comment that ends with a ". instead of the ." like it should. TextFieldParser then throws a MalformedLineException and causes my program to halt processing of the file and continue on to push the data it has into the database.
I really don't care about the data on any lines that would have that on them so what I am looking for is what is the best way to skip reading that line and continue on with the file?
I catch the exception (see below) and thought about changing the delimiter to nothing and setting it to not delimited and reading the line then setting it back to delimited. However not sure that would be the best way or if it would even work (since I have not tired it yet).
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox(ex.Message & " - Malformed line exception.")
MSDN documentation is sorely lacking (as usual) on these kinds of things and I have not been able to find anything else on the subject.
Any help is (as always) appreciated.
shawn