C# Класс Kajabity.Tools.Csv.CsvReader

This class reads CSV formatted data from an input stream. It can read individual fields in a row, a full row or the whole file. Data can only be read once - so if the first field in a row is read, it won't be part of the row if that is read next. The term Row is used rather than line because quoted fields can include line breaks (real, not escaped) so that one row may be spread across multiple lines.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Quote int
Separator int

Открытые методы

Метод Описание
CsvReader ( Stream stream ) : System.Collections

Construct a inStream.

ReadAll ( ) : string[][]

Reads all fields and records from the CSV input stream from the current location.

ReadField ( ) : string

Reads the next field on the current line - or null after the end of the line. The field will not be part of the next ReadLine or ReadFile.

ReadRecord ( ) : string[]

Read to the end of the current record, if any.

Приватные методы

Метод Описание
DoAction ( int action, int ch ) : void

Performs the action associated with a state transition.

Matches ( int match, int ch ) : bool

Tests if the current character matches a test (one of the MATCH_* tests).

NextChar ( ) : int

Returns and removes the next character from the input stream - including any that have been peeked and pushed back.

Parse ( int finalSate ) : void

Parse the input CSV stream from the current position until the final state is reached. Intended to allow parsing to End of Field, End of Record or End of File.

PeekChar ( ) : int

Retuns but doesn't remove the next character from the stream. This character will be returned every time this method is called until it is returned by NextChar().

Описание методов

CsvReader() публичный Метод

Construct a inStream.
public CsvReader ( Stream stream ) : System.Collections
stream System.IO.Stream The input stream to read from.
Результат System.Collections

ReadAll() публичный Метод

Reads all fields and records from the CSV input stream from the current location.
public ReadAll ( ) : string[][]
Результат string[][]

ReadField() публичный Метод

Reads the next field on the current line - or null after the end of the line. The field will not be part of the next ReadLine or ReadFile.
public ReadField ( ) : string
Результат string

ReadRecord() публичный Метод

Read to the end of the current record, if any.
public ReadRecord ( ) : string[]
Результат string[]

Описание свойств

Quote публичное свойство

Gets or sets the quote character used in the CSV stream - default value is a double quote ('"').
public int Quote
Результат int

Separator публичное свойство

Gets or sets the separator character used in the CSV stream - default value is a comma (',').
public int Separator
Результат int