Share via


TextFieldParser Object MembersĀ 

The TextFieldParser object provides methods and properties for parsing structured text files as shown in the following table.

Properties

CommentTokens

String. Lines beginning with the specified comment token are skipped by the parser.

Delimiters

String. The delimiters for the text file. Valid only for delimited files.

EndOfData

Boolean. Returns True if there are no non-blank, non-comment lines between the current cursor position and the end of the file.

ErrorLine

String. Returns the line that caused the most recent MalformedLineException. Default is "".

ErrorLineNumber

Long. Returns the line number that caused the most recent MalformedLineException. Default is -1.

FieldWidths

Integer. Denotes the width of each column in the text file. Valid only for fixed-width files.

HasFieldsEnclosedInQuotes

Boolean. Returns True if fields can be enclosed in quotation marks. Valid only for delimited files. Default is True.

LineNumber

Integer. Returns the current line number, or -1 if no more characters are available.

TextFieldType

FieldType. The type of file, delimited or fixed-width. Default is Delimited.

TrimWhiteSpace

Boolean. Indicates whether leading and trailing white spaces should be trimmed from field values.

Methods

Close

Closes the underlying stream.

PeekChars

Reads the specified number of characters without advancing the cursor.

ReadFields

Reads all fields on the current line, returns them as an array of strings, and advances cursor to the next line.

ReadLine

Returns the current line as a String and advances the cursor to the next line.

ReadToEnd

Reads the remainder of the stream and returns it as a String.

SetDelimiters

Sets the delimiters for the reader to the specified values and the field type to Delimited.

SetFieldWidths

Sets the delimiters for the reader to the specified values and the field type to FixedWidth.

See Also

Reference

TextFieldParser Object

Concepts

Parsing Text Files with the TextFieldParser Object