[gdal-dev] Autodetect "0012" as string in CSV

Rahkonen Jukka (MML) jukka.rahkonen at maanmittauslaitos.fi
Fri Aug 18 03:59:47 PDT 2017


Hi,

The schema of a CSV file like this
"00012",012345,1234,234.65,"text"
is autodetected this way:

ogrinfo csvtext.csv -oo autodetect_type=yes -al
INFO: Open of `csvtext.csv'
      using driver `CSV' successful.

Layer name: csvtext
Geometry: None
Feature Count: 1
Layer SRS WKT:
(unknown)
field_1: Integer (0.0)
field_2: Integer (0.0)
field_3: Integer (0.0)
field_4: Real (0.0)
field_5: String (0.0)
OGRFeature(csvtext):1
  field_1 (Integer) = 12
  field_2 (Integer) = 12345
  field_3 (Integer) = 1234
  field_4 (Real) = 234.65
  field_5 (String) = text

It would be good to autodetect also "00012" as a string. Double quotes are correctly stripped of from "text" so I suppose that GDAL already knows that they are used for enclosing strings.

See https://gis.stackexchange.com/questions/252482/keeping-leading-zeroes-in-qgis-in-big-files

-Jukka Rahkonen-


More information about the gdal-dev mailing list