Opened 6 years ago

Closed 6 years ago

#7180 closed defect (fixed)

Newer versions of ogr2ogr add trailing space to first line when exporting shapefile as CSV

Reported by: dtarc Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 1.11.5
Severity: normal Keywords: csv trailing comma
Cc:

Description (last modified by dtarc)

We've been using ogr2ogr on the command line in our web app to read shapfiles. We do this by exporting them as csv.

We were stuck at 1.8 for a while and we'd like to update to 1.11.5, but the csv output has changed ever so slightly.

When we export as CSV (from shapefile) in 1.11.5 (I think anything 1.10 and up), we are getting a trailing comma in the first line (CSV header).

We were not getting this with 1.8.1. No trailing comma on first line.

With 1.8.1:

honeybadger dtarc$ /usr/local/bin/ogr2ogr -f CSV /vsistdout/ "/path/to/FNC_Boundary_171-15214-00-000-00-PIPSK001-R0.shp" -lco GEOMETRY=AS_WKT -t_srs EPSG:4326
WKT,LAYER
"POLYGON ((-111.687865301732529 57.317167255164847,-111.68977462743706 57.317047746960327,-111.693918462030922 57.316921356923281,-111.694065071370204 57.317006816282436,-111.689788844553263 57.317137246834108,-111.688032762074471 57.317247164303375,-111.688052798287885 57.318318126427947,-111.688973545696584 57.318899775087338,-111.688847492980486 57.318958183157086,-111.68788745591786 57.318351712829873,-111.687865301732529 57.317167255164847))",FNC_Boundary

With 1.11.5:

honeybadger dtarc$ /usr/local/bin/ogr2ogr -f CSV /vsistdout/ "/path/to/FNC_Boundary_171-15214-00-000-00-PIPSK001-R0.shp" -lco GEOMETRY=AS_WKT -t_srs EPSG:4326
WKT,LAYER,
"POLYGON ((-111.687865301732529 57.317167255164847,-111.68977462743706 57.317047746960327,-111.693918462030922 57.316921356923281,-111.694065071370204 57.317006816282436,-111.689788844553263 57.317137246834108,-111.688032762074471 57.317247164303375,-111.688052798287885 57.318318126427947,-111.688973545696584 57.318899775087338,-111.688847492980486 57.318958183157086,-111.68788745591786 57.318351712829873,-111.687865301732529 57.317167255164847))",FNC_Boundary

I have included the file for testing.

This is an easy enough thing for us to adjust for in our code, if it's really jut a comma that shouldn't be there. However, we don't know if it is larger issue than that.

We are also using ogr2ogr to process KML files as CSV, and the CSV files from the KML never have a trailing slash in the header line, no matter what version of ogr2ogr we use.

We're not sure if this is just a glitch in ogr2ogr or if there's something going on in the shapefile that we don't understand.

Thanks

Attachments (1)

shape-files-9-10-basal-pl.zip (1.9 KB ) - added by dtarc 6 years ago.

Download all attachments as: .zip

Change History (3)

by dtarc, 6 years ago

comment:1 by dtarc, 6 years ago

Description: modified (diff)

comment:2 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

This issue has been fixed in GDAL 2.1 and above. Please consider upgrading to GDAL 2.2.3. Older versions are no longer supported

Note: See TracTickets for help on using tickets.