Declaration¶
Source position: csvreadwrite.pp line 109
type
TCSVParser = class(TCSVHandler)
public
constructor Create;
destructor Destroy;
procedure SetSource(AStream: TStream); overload;
procedure SetSource(const AString: string); overload;
procedure ResetParser;
function ParseNextCell : Boolean;
property CurrentRow: Integer; {r}
property CurrentCol: Integer; {r}
property CurrentCellText: string; {r}
property MaxColCount: Integer; {r}
property FreeStream: Boolean; {rw}
property BOM: TCSVByteOrderMark; {r}
property DetectBOM: Boolean; {rwd}
end;
Inheritance¶
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.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| BOM read only | public | type of BOM marker found at the start of the data. |
| CurrentCellText read only | public | Current field value. |
| CurrentCol read only | public | Column (zero based) of the current field. |
| CurrentRow read only | public | Row (zero based) of the current field. |
| DetectBOM | public | Must the parser attempt to read the BOM marker ? |
| FreeStream | public | Does the parser free the stream when done ? |
| MaxColCount read only | public | Return the maximum column count encountered till now. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| Create | public | Create a new instance of TCSVParser. |
| Destroy | public | Free the TCSVParser instance. |
| ParseNextCell | public | Parse the next cell. |
| ResetParser | public | Reset the parser to its initial state. |
| SetSource | public | Set the CSV source data. |
See also¶
| Name | Description |
|---|---|
| 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. |