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

2017-08-18 Thread Rahkonen Jukka (MML)
Hi Even,


Yeah, should have been reading the documents more closely. This keeps the 
leading zeroes.


ogrinfo csvtext.csv -oo autodetect_type=yes -oo quoted_fields_as_string=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: String (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 (String) = 00012
  field_2 (Integer) = 12345
  field_3 (Integer) = 1234
  field_4 (Real) = 234.65
  field_5 (String) = text


-Jukka-



Lähettäjä: Even Rouault <even.roua...@spatialys.com>
Lähetetty: 18. elokuuta 2017 14:30
Vastaanottaja: gdal-dev@lists.osgeo.org
Kopio: Rahkonen Jukka (MML)
Aihe: Re: [gdal-dev] Autodetect "0012" as string in CSV


On vendredi 18 août 2017 10:59:47 CEST Rahkonen Jukka (MML) wrote:

> 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.



Jukka,



Add -oo QUOTED_FIELDS_AS_STRING=YES



I don't remember the rationale for the default of this option to be NO. 
Presumably the use case while developping that was with a file generated by a 
CSV exporter always surrounding field content by double quotes.



Even



--

Spatialys - Geospatial professional services

http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

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

2017-08-18 Thread Even Rouault
On vendredi 18 août 2017 10:59:47 CEST Rahkonen Jukka (MML) wrote:
> 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.

Jukka,

Add -oo QUOTED_FIELDS_AS_STRING=YES

I don't remember the rationale for the default of this option to be NO. 
Presumably the use 
case while developping that was with a file generated by a CSV exporter always 
surrounding 
field content by double quotes.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

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

2017-08-18 Thread Rahkonen Jukka (MML)
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-
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev