Project Description

TextFileParsers is a library written C# that makes it easier for programmers to parse structured text files, both delimited and fixed width text files.

It is inspired in the TextFieldParser class from VisualBasic.FileIO namespace but refactored to allow better extensibility.


This library contains a small hierarchy of classes that allow to easily parse structured text files but also sets the bases for implementing a specialized field parser if needed.

The included classes are:
  • StructuredTextParser is an abstract base class from which both DelimitedFieldParser and FixedWidthFieldParser are derived. Specialized parsers just need to override the ReadFields method to provide their own implementation.
  • DelimitedFieldParser provides methods and properties for parsing delimited text files such as comma separated values files (csv) or tab delimited files often used for the interchange of information between applications.
  • FixedWidthFieldParser provides methods and properties for parsing structured text files, such as logs, whose fields have fixed widths.
  • TextFields provides access to the field values within each line.

Parsing a text file with both DelimitedFieldParser and FixedWidthFieldParser is similar to iterating over a text file, using the ReadFields method to read fields values.

Basic usage guides

Read from a delimited text file
Read from a fixed-width text file

Find TextFileParsers useful?

Buy me a beer


All feedback and suggestions will be much appreciated.

Last edited Jul 13, 2009 at 12:53 AM by mtricoli, version 10