C# Class 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.
Afficher le fichier Open project: Kajabity/Kajabity-Tools Class Usage Examples

Méthodes publiques

Свойство Type Description
Quote int
Separator int

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
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().

Method Details

CsvReader() public méthode

Construct a inStream.
public CsvReader ( Stream stream ) : System.Collections
stream System.IO.Stream The input stream to read from.
Résultat System.Collections

ReadAll() public méthode

Reads all fields and records from the CSV input stream from the current location.
public ReadAll ( ) : string[][]
Résultat string[][]

ReadField() public méthode

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
Résultat string

ReadRecord() public méthode

Read to the end of the current record, if any.
public ReadRecord ( ) : string[]
Résultat string[]

Property Details

Quote public_oe property

Gets or sets the quote character used in the CSV stream - default value is a double quote ('"').
public int Quote
Résultat int

Separator public_oe property

Gets or sets the separator character used in the CSV stream - default value is a comma (',').
public int Separator
Résultat int