Unit 'csvreadwrite' Package
[Overview][Types][Classes][Procedures and functions][Index] [#fcl]

TCSVParser

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Class to parse a CSV file.

Declaration

Source position: csvreadwrite.pp line 102

type TCSVParser = class(TCSVHandler)

public

  constructor Create; override;

  

Create a new instance of TCSVParser.

  destructor Destroy; override;

  

Free the TCSVParser instance.

  procedure SetSource();

  

Set the CSV source data.

  procedure ResetParser;

  

Reset the parser to its initial state.

  function ParseNextCell;

  

Parse the next cell.

  property CurrentRow: Integer; [r]

  

Row (zero based) of the current field.

  property CurrentCol: Integer; [r]

  

Column (zero based) of the current field.

  property CurrentCellText: string; [r]

  

Current field value.

  property MaxColCount: Integer; [r]

  

Return the maximum column count encountered till now.

  property FreeStream: Boolean; [rw]

  

Does the parser free the stream when done ?

  property BOM: TCSVByteOrderMark; [r]

  

type of BOM marker found at the start of the data.

  property DetectBOM: Boolean; [rw]

  

Must the parser attempt to read the BOM marker ?

end;

Inheritance

TCSVParser

  

Class to parse a CSV file.

|

TCSVHandler

  

Base class for CSV reading and writing classes.

|

TPersistent

|

TObject,IFPObserved

Description

TCSVParser can be used to read a CSV file. To use it, the stream or string containing the CSV data must be specified with SetSource, after which ParseNextCell can be called till it returns false. The current cell value after ParseNextCell returns True is available in CurrentCellText. By tracking CurrentRow, CurrentCol and MaxColCount, the structure of the CSV file can be determined.

See also

SetSource

  

Set the CSV source data.

ParseNextCell

  

Parse the next cell.

CurrentCellText

  

Current field value.

CurrentRow

  

Row (zero based) of the current field.

CurrentCol

  

Column (zero based) of the current field.

MaxColCount

  

Return the maximum column count encountered till now.


Documentation generated on: Jul 24 2023