Sign in Join
FPDoc Onlineexperiment

TCSVParser class

In unit CsvReadWrite

Class to parse a CSV file.

Declaration

pascal
TCSVParser = class(TCSVHandler)

Inheritance

  1. TCSVParser
  2. TCSVHandler
  3. TPersistent
  4. TObject

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

Properties

CurrentRowpublicRow (zero based) of the current field.
CurrentColpublicColumn (zero based) of the current field.
CurrentCellTextpublicCurrent field value.
MaxColCountpublicReturn the maximum column count encountered till now.
FreeStreampublicDoes the parser free the stream when done ?
BOMpublictype of BOM marker found at the start of the data.
DetectBOMpublicMust the parser attempt to read the BOM marker ?

Methods

CreatepublicCreate a new instance of TCSVParser.
DestroypublicFree the TCSVParser instance.
SetSourcepublicSet the CSV source data.
ResetParserpublicReset the parser to its initial state.
ParseNextCellpublicParse the next cell.

Inherited

From TCSVHandler (8)

Assign AssignCSVProperties Delimiter EqualColCountPerRow IgnoreOuterWhitespace LineEnding QuoteChar QuoteOuterWhitespace

From TPersistent (7)

AssignTo DefineProperties FPOAttachObserver FPODetachObserver FPONotifyObservers GetNamePath GetOwner

From TObject (40)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.