Comma Separated Values

The GDAL CSV file format provides a simple but effective way to interchange point data. Files may be loaded directly into Vizex using drag and drop, or from the Display | GIS form (on the Home tab or the Vizex tab, in the Layer group).

  • By default, the OGR CSV driver will treat the first line of the file as a list of field names. However, if one or more of the field values is numeric, the first line is treated as a feature (record) and default field names (Field_1 ... Field_n) will be generated.
  • The file must have one line for each feature (record) in the layer (table).
  • At least two fields per line must be present.
  • Each record should have the same number of fields.
  • Note: The driver can auto-detect a semicolon, a tab, or a space as the field separator. However, this auto-detection will only work as long as there are no other potential separators on the first line of the file. Otherwise, the driver will default to a comma separator.

  • Lines in the file may be terminated by a DOS (CR/LF) or Unix (LF) line terminator.
  • Complex attribute values (such as those containing commas, quotes or newlines) may be placed in double quotes. Any occurrences of double quotes within the quoted string should be doubled up to "escape" them.
  • Starting with GDAL 1.9.0 numeric values are treated as field names if they are enclosed in double quotes. Starting with GDAL 2.1, this behaviour can be modified via the HEADERS open option.
  • All CSV files are treated as UTF-8 encoded.
  • Starting with GDAL 1.9.0, a Byte Order Mark (BOM) at the beginning of the file will be parsed correctly. From 1.9.2, the option WRITE_BOM can be used to create a file with a Byte Order Mark, which can improve compatibility with some software (particularly Excel).

Example (Holes.csv):

HOLE,EAST,NORTH,Z,DTM, DESCRIPTION
DDH001,24708.00,15670.00,1521.61,A,Pit
DDH002,24728.00,15670.00,1516.42,B,Pit
DDH003,24766.00,15670.00,1509.71,C,Dump 
DDH004,24902.00,15900.00,1544.00,E,"Dump ""Backfill"""	

Note:

The Description value for the last record (above) is placed in double quotes because the value contains quotes, and those quotes have to be doubled up so we know we have yet to reach the end of the quoted string.

Scripts or text editors that support recordable macros, such as Notepad ++, can be used to convert non-compatible CSV file formats into a form that is compatible with the OGR CSV driver.

For more information on reading CSV file data containing spatial information, see: http://www.gdal.org/drv_csv.html