Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#2756 closed defect (fixed)

NULLs in a CSV file are treated as 0 (zero).

Reported by: cgsbob Owned by: warmerdam
Priority: normal Milestone: 1.7.0
Component: OGR_SF Version: 1.6.0
Severity: normal Keywords: csv null values
Cc:

Description

ogr2ogr on a VRT produces 0 (zero) instead of NULL.

Here is some background info:

psha2002.vrt:

<OGRVRTDataSource>
  <OGRVRTLayer name="psha2002_bayarea">
    <SrcDataSource>/tmp/psha2002_bayarea.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>NAD27</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="longitude" y="latitude"/>
  </OGRVRTLayer>
</OGRVRTDataSource>

psha2002_bayarea.csvt

"Real","Real","Real","Real","Real","Real","Real","Real"

A few lines from psha2002_bayarea.csv:

longitude,latitude,pga_bc,pgamw_bc,modal_distance,modal_mag,pga_d,pgamw_d
-123,38.25,0.666,0.732,,,0.666,0.732
-122.99,38.25,0.694,0.77,,,0.694,0.77
-122.98,38.25,0.701,0.778,,,0.701,0.778

modal_distance and modal_mag have zero values where there should be nulls.

Change History (2)

comment:1 by Even Rouault, 15 years ago

Keywords: csv null values added
Milestone: 1.7.0
Resolution: fixed
Status: newclosed

I've fixed that in trunk in r15999 for all data types except for strings, as we have no way of distinguish empty string ( ,"", ) from NULL string ( ) in the return values of CSVReadParseLine(). I'm not sure that this distinction makes sense in a CSV file anyway.

comment:2 by warmerdam, 15 years ago

Component: defaultOGR_SF

I agree that NULL is not a meaningful concept for string fields in a CSV file.

Note: See TracTickets for help on using tickets.