1

I have a csv that I'm trying to import in postgres with postgis enabled but can't seem to get the EWKB field to work. I have created a table:

CREATE TABLE sample_data ( id character varying(200) NOT NULL, uid character varying(200) NOT NULL, point_geom geometry(Point,4326) NOT NULL);

and then copied the data from the csv into it:

COPY sample_data FROM 'D:/Workspace/sample_data.csv' DELIMITER ',' CSV;

Sample CSV: "id","uid","point_geom" "1953642","12359234","0101000020E610000030629F008AB937407D2079E750FC4240"

Error I get from Postgres is: ERROR: parse error - invalid geometry SQL state: XX000 Hint: "point_g" <-- parse error at position 7 within geometry Context: COPY sample_data, line 1, column point_geom: "point_geom"

Anyone have any ideas? That error is not exactly the clearest to me...

1 Answer 1

3

PostGIS is reporting a parse error because it's reading the header row and trying to parse the text "point_geom" as a geometry. You can instruct COPY to skip the header row by adding the HEADER flag to your command:

COPY sample_data FROM 'D:/Workspace/sample_data.csv' DELIMITER ',' CSV HEADER;
1
  • That got it. Thanks man that was driving me up a wall. Commented Aug 29, 2016 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.