[gdal-dev] Re: Creating shape file from csv with double quotes in attribute

Hermann Peifer peifer at gmx.eu
Sat Sep 11 09:11:12 EDT 2010


On 10/09/2010 18:16, Upendra Dadi wrote:
> Hi,
> I have a query on creating shapefile from csv. I am not sure if this is
> the correct forum for it. Thought I should try it anyway.
> I have a csv file consisting of lat/lon and an attribute with double
> quotes like this:
> "<a
> href="http://data.nodc.noaa.gov/thredds/dodsC/gtspp/atlantic/2010/07/9670278.nc.html"
> target="_blank">Data URL</a>"
>
> When I create the shape file from this file using a vrt file, the shape
> file has this value for the attribute:
> <a
> href=http://data.nodc.noaa.gov/thredds/dodsC/gtspp/atlantic/2010/07/9670278.nc
>
>
> As you can see, the double quotes are gone and the attribute is
> truncated. How do I overcome this problem? Any help is appreciated.
>

I managed to fix the quote issue with: sed 's/"/"""/g'

The truncation issue comes from the shapefile driver's default width for 
string fields (80 characters). But one can create a .csvt file, as 
explained at: http://www.gdal.org/ogr/drv_csv.html

I copied some more details to here (for better readability): 
http://pastebin.com/6yeAzAZc

Hermann


More information about the gdal-dev mailing list