Declaration: TDataTable.ImportCSVFile (FName: string; Delimiter: TCSVDelimiters; IncludeColHeaders, IncludeRowHeaders: boolean): integer;
The method ImportFromCSV reads the CSV file (comma separated values file) FName. The parameter Delimiter determines the delimiting character used in the CSV file. Setting the Delimiter to csvUnknown forces the routine to determine the delimiting character automatically by counting the number of occurrences of the possible separator characters. The one with the highest rate of occurrence is considered to be the delimiting character. This approach should work in most of the cases. If not, you can specify a particular delimiting character by setting the Delimiter parameter to the corresponding value.

If the parameter IncludeColHeaders is set to TRUE the first row is interpreted as the column headings, if IncludeRowHeaders is set to TRUE the first column of the data array is interpreted as row headings. The function returns a zero value if the CSV file has been read successfully.

The method ImportFromCSV assigns nominal values automatically whenever a non-numeric cell is read. However, this may result in inconsistencies if numeric and non-numeric cells are mixed within a particular column. Further, you should keep in mind that nominal and ordinal values cannot be distinguished by the import routine, thus the corresponding column is always set to the nominal scale type.

The method returns the following error codes:

 0 ... everything is OK
-1 ... too many nominal identifiers

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 you should always be careful to select the proper delimiter, exspecially when writing software for multi-language environments.