Sign in Join
FPDoc Onlineexperiment

LoadFromCSVFile procedure

In unit LCSVUtils

Loads and processes comma-separated values from the specified file.

Declaration

pascal
procedure LoadFromCSVFile(aFilename: string; AProc: TCSVRecordProc; 
                         ADelimiter: char=','; 
                         CSVEncoding: TCSVEncoding=ceAuto)

Arguments

aFilename

File name which contains the CSV data.

AProc

Routine used to load and process lines in the CSV data.

ADelimiter

Delimiter used to separate fields in the CSV data.

CSVEncoding

Character encoding used for the CSV data.

Description

LoadFromCSVFile is a procedure used to read and process delimited values from the file specified in the AFilename argument.

The procedure name is actually a misnomer; the routine uses the value in ADelimiter as the delimiter between field values. It does not have to be a Comma (,) character. Comma is, however, the default value for the ADelimiter argument.

LoadFromCSVFile reads lines of data from the file, and converts the encoded byte values to fields which are processed and applied using the procedure in AProc. Internally, it creates a temporary TFileStream instance for the specified file name. The LoadFromCSVStream routine is called to read and apply the content using the arguments in AProc, ADelimiter, and CSVEncoding.

See LoadFromCSVStream for more information about the arguments passed to the routine, and how the procedure is implemented.

See also

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