Re: Import from CSV error

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: James David Smith <james(dot)david(dot)smith(at)gmail(dot)com>, "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Import from CSV error
Date: 2013-10-30 17:46:04
Message-ID: 527145DC.5060406@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 10/28/2013 04:58 AM, James David Smith wrote:
> Hi,
>
> Does anyone know why this doesn't work please?
>
> DROP TABLE temp;
> CREATE TABLE temp(id integer);
> SELECT AddGeometryColumn('temp', 'the_geom', 4326, 'LINESTRING', 2);
> COPY temp FROM 'C:/Program Files/PostgreSQL/9.2/data/tube_o_r.txt'
> DELIMITER ';';
>
> ERROR: parse error - invalid geometry
> HINT: "ST" <-- parse error at position 2 within geometry
> CONTEXT: COPY temp, line 1, column the_geom:
> "ST_GeomFromText('LINESTRING(-0.11453 51.50366,-0.11450
> 51.50369,-0.11422 51.50404,-0.11392 51.50397,..."
>
> My file is a txt file, with no headers, with the two columns separated
> by a semi-colon. Line one of the file is shown below:
>
> 1;ST_GeomFromText('LINESTRING(-0.11453 51.50366,-0.11450
> 51.50369,-0.11422 51.50404,-0.11392 51.50397,-0.11367
> 51.50392,-0.11327 51.50384,-0.11329 51.50381,-0.11329
> 51.50381,-0.11512 51.50310,-0.11497 51.50312,-0.11500
> 51.50321,-0.11513 51.50350,-0.11555 51.50383,-0.11602
> 51.50405,-0.11814 51.50467,-0.11880 51.50497,-0.12130
> 51.50631,-0.12184 51.50647,-0.12285 51.50668,-0.12285
> 51.50668,-0.12487 51.50710,-0.12590 51.50724,-0.12807
> 51.50743,-0.12807 51.50743,-0.12965 51.50757,-0.13080
> 51.50769,-0.13104 51.50776,-0.13125 51.50788,-0.13176
> 51.50851,-0.13203 51.50884,-0.13306 51.50983,-0.13346
> 51.50997,-0.13392 51.51001,-0.13527 51.50996,-0.13527
> 51.50996,-0.13631 51.50992,-0.13696 51.50991,-0.13735
> 51.50997,-0.13769 51.51007,-0.13800 51.51023,-0.13832
> 51.51050,-0.13876 51.51102,-0.14143 51.51405,-0.14187
> 51.51451,-0.14226 51.51570,-0.14226 51.51570,-0.14154
> 51.51524,-0.14157 51.51532,-0.14163 51.51532,-0.14178 51.51530)',
> 4326)
>
Since this has gone unanswered for a couple days I'll venture a _guess_
based on little (~0) experience with PostGIS.

I *suspect* that the input file should only have the Well Known Text
(WKT) representation of the linestring and should not have the
ST_GeomFromText constructor function as part of the input.

Geogeeks? Is this right or wrong?

Cheers,
Steve

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David Johnston 2013-10-30 18:18:25 Re: Import from CSV error
Previous Message Payal Singh 2013-10-30 15:39:29 Re: Double Free or corruption