Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static method: IEnumerable<string[]> ParseCsv(TextReader, int)

  • Declared in: RT.Util.Ut

Declaration

public static IEnumerable<string[]> ParseCsv(
    TextReader reader,
    int minColumns = 0
)

Summary

Parses text from the reader as CSV. See Remarks.

Parameters

TextReaderreader Text reader containing the text to parse.
intminColumns The minimum number of columns to return for each row. Any row with fewer columns than this is padded with empty string values to meet this minimum.

Returns

An enumeration of rows, with each row represented by an array of column values.

Remarks

Does not attempt to handle header columns in any way whatsoever.

Empty rows (rows with zero columns) are skipped. Rows with only empty columns ("") are enumerated normally. This behaviour is unaffected by the minColumns setting.

As suggested by RFC 4180, spaces around commas are significant: a leading space is interpreted as the beginning of an un-quoted value, and a trailing space after a quoted value is an error.

This method enumerates rows as they are parsed, meaning that a parse exception may occur after a number of rows have already been yielded.