[postgis-users] Import excel file to postgresql

153 views
Skip to first unread message

José María Amuedo

unread,
Jun 13, 2012, 9:46:20 AM6/13/12
to PostGIS Users Discussion
Hi,

I would like to know how can import excel file to postgresql. I'm working with linux OS.

Thanks

Pedro Costa

unread,
Jun 13, 2012, 9:49:01 AM6/13/12
to PostGIS Users Discussion
Hi José,

You have to convert the excel file to csv and use the copy command like that:


copy table_name from 'C:\Users\TEMP\filename.csv' WITH CSV DELIMITER ';';


You have to create the table before and delete the column names of csv file.
_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Horst Düster

unread,
Jun 13, 2012, 9:57:27 AM6/13/12
to postgi...@postgis.refractions.net
As an other option you can use an ETL-Tool like Talend OpenStudio [1] or Geokettle [2]

Regards
Horst

[1] http://www.talend.com/index.php
[2] http://www.spatialytics.org/projects/geokettle/

Ralf Suhr

unread,
Jun 13, 2012, 10:10:41 AM6/13/12
to postgi...@postgis.refractions.net

Hi José,

 

ogr2org can import excel files for you. http://www.gdal.org/ogr/drv_xls.html Or you compile gdal/ogr from svn then you can also import xlsx files. http://www.gdal.org/ogr/drv_xlsx.html

 

 

Gr

Ralf

José María Amuedo

unread,
Jun 13, 2012, 10:34:37 AM6/13/12
to PostGIS Users Discussion
I obtened this error:

RROR: extra data after last expected column
SQL state: 22P04
Context: COPY nueva, line 1: "CODIGO;TIPO;DESCRIPCION;REPRESENTACION;PERFIL;CLAVE;VER3D;CARACBUSQ;LETRA;CAPITULO;SUBCAPITULO;ESTA;..."

2012/6/13 Pedro Costa <pedroco...@sapo.pt>

Pedro Costa

unread,
Jun 13, 2012, 10:38:46 AM6/13/12
to PostGIS Users Discussion
Send me a sample of your file. But you have to remove the last semicolon.

Your file have to be like that:


column1;column2;column3;333333.3333
column1_r2;column2_r2;column3_r2;333333.3333

José María Amuedo

unread,
Jun 13, 2012, 10:50:30 AM6/13/12
to PostGIS Users Discussion
this is my file

2012/6/13 Pedro Costa <pedroco...@sapo.pt>
elements.csv

Pedro Costa

unread,
Jun 13, 2012, 10:55:15 AM6/13/12
to postgi...@postgis.refractions.net

Try with i sample attached.
be sure that your table must have columns according to the file
elements.csv
Reply all
Reply to author
Forward
0 new messages