Loading geometrys from csv

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Loading geometrys from csv

John K
Hello,

I have a .csv file with a geometry, and I'm trying to load into a table.

copy public.test FROM '/home/john/test.csv' with (FORMAT csv, DELIMITER E',' )

The csv file has 4 columns and looks like:
1,113,31200,\x010600000001000000010300000001000000ba0a00008717...

I'm getting an error:
ERROR:  parse error - invalid geometry
HINT:  "\x" <-- parse error at position 2 within geometry
CONTEXT:  COPY test, line 2, column geom:
"\x01060000000100000001030000000100000042050000ac1c5a643b4d55c0333674b33f3c40401daa29c93a4d55c0333674..."

Is there anything obvious I'm doing wrong?

Thanks in advance,
John
_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Loading geometrys from csv

Regina Obe-2
That looks like WKB format.

What you could try is:

Change your geometry column in public.test to bytea

And then after you are done loading

ALTER TABLE public.test ALTER COLUMN geom TYPE geometry USING ST_GeomFromWB(geom);



-----Original Message-----
From: postgis-users [mailto:[hidden email]] On Behalf Of John K
Sent: Friday, May 05, 2017 8:18 PM
To: [hidden email]
Subject: [postgis-users] Loading geometrys from csv

Hello,

I have a .csv file with a geometry, and I'm trying to load into a table.

copy public.test FROM '/home/john/test.csv' with (FORMAT csv, DELIMITER E',' )

The csv file has 4 columns and looks like:
1,113,31200,\x010600000001000000010300000001000000ba0a00008717...

I'm getting an error:
ERROR:  parse error - invalid geometry
HINT:  "\x" <-- parse error at position 2 within geometry
CONTEXT:  COPY test, line 2, column geom:
"\x01060000000100000001030000000100000042050000ac1c5a643b4d55c0333674b33f3c40401daa29c93a4d55c0333674..."

Is there anything obvious I'm doing wrong?

Thanks in advance,
John
_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Loading geometrys from csv

Regina Obe-2
In reply to this post by John K
Oops typo meant:

ALTER TABLE public.test ALTER COLUMN geom TYPE geometry USING ST_GeomFromWKB(geom);

As Mark mentioned (if bytea doesn't work try text for column type).



-----Original Message-----
From: Regina Obe [mailto:[hidden email]]
Sent: Sunday, May 07, 2017 5:57 AM
To: 'PostGIS Users Discussion' <[hidden email]>
Subject: RE: [postgis-users] Loading geometrys from csv

That looks like WKB format.

What you could try is:

Change your geometry column in public.test to bytea

And then after you are done loading

ALTER TABLE public.test ALTER COLUMN geom TYPE geometry USING ST_GeomFromWB(geom);



-----Original Message-----
From: postgis-users [mailto:[hidden email]] On Behalf Of John K
Sent: Friday, May 05, 2017 8:18 PM
To: [hidden email]
Subject: [postgis-users] Loading geometrys from csv

Hello,

I have a .csv file with a geometry, and I'm trying to load into a table.

copy public.test FROM '/home/john/test.csv' with (FORMAT csv, DELIMITER E',' )

The csv file has 4 columns and looks like:
1,113,31200,\x010600000001000000010300000001000000ba0a00008717...

I'm getting an error:
ERROR:  parse error - invalid geometry
HINT:  "\x" <-- parse error at position 2 within geometry
CONTEXT:  COPY test, line 2, column geom:
"\x01060000000100000001030000000100000042050000ac1c5a643b4d55c0333674b33f3c40401daa29c93a4d55c0333674..."

Is there anything obvious I'm doing wrong?

Thanks in advance,
John
_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-users
Loading...