[postgis-users] Excel to Postgres

Mike Toews mwtoews at gmail.com
Mon Feb 15 13:26:50 PST 2010


Hi Steve,

If you have done some dabbling with Python (or you are willing to
dabble), use xlrd to read Excel files
(http://pypi.python.org/pypi/xlrd) then either pyodbc (recommended for
Windows) or psycopg2 to connect to Postgres and transfer the data
over. Make it into a script, then repeat as necessary. If you want to
get user-friendly, then make a shortcut to a bat file that runs the
python script, then you can import the file by dragging-dropping an
Excel file over the shortcut.

-Mike

On 15 February 2010 13:03,  <Steve.Toutant at inspq.qc.ca> wrote:
>
> Hi,
> Every day I receive an Excel file containing lat long coordinates. I need to
> import it to postgis.
> Currently, I save the Excel file in CSV format and I use ogr2ogr to import
> the contents into postgis. I would like to avoid human intervention.
>
> I tried unsuccessfully  to define an ODBC link on the Excel file and use
> ogr2ogr with odbc to import it to postgres/postgis.
> I got this error
> [Microsoft][ODBC Excel Driver] External table is not in the expected format
>
> Here is the command I sent
> ogr2ogr -f "PostgreSQL" PG:"host=xxx user=xxx password=xxx dbname=geo"
> "ODBC:odbc_urg,test" -nln "testODBCxls" -overwrite
>
> where test is the sheet name inside the excel file
>
> Anyone has a better idea on how to programmatically import excel data into
> postgis?
> thanks
> Steve
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



-- 

Sent from Vancouver, British Columbia, Canada



More information about the postgis-users mailing list