ExportAsCSVFile

Declaration: TDataTable.ExportAsCSVFile (FName: string; Precision: integer; Delimiter: TCSVDelimiters; IncludeColHeaders, IncludeRowHeaders, IncludeRowAttributes, IncludeComment: boolean): integer;
The method ExportAsCSVFile writes the contents of the data table along with optional additional information (headers, etc.) to the CSV file FName. The parameter Precision controls the number of significant digits used for storing the data. The delimiting character is specfied by the parameter Delimiter. If Delimiter is set to csvUnknown it defaults to csvComma.

The parameters IncludeColHeaders and IncludeRowHeaders control whether the column and row headers are exported, as well. Nominal and ordinal values are exported using their nominal identifiers. The parameter IncludeRowAttributes controls whether the row attributes are exported as well. The parameter IncludeComment determines whether the comment of the data table is included in the CSV file.

The method returns the following error codes:

 0 ... everything is OK
-1 ... a problem occurred during opening the file (e.g. 'file access denied' for read-only files)

Hint: Please note that the CSV format has never been standardized, and thus a plethora of different sub-versions exists. Further, the decimal separator and the thousand separator character change between different languages, contributing to even greater confusion. For example, in German implementations the comma is replaced by the semicolon in order to be able to use the comma as a decimal separator. Thus the selection of the delimiter depends on the system which will be used to read the CSV file.