On mardi 15 novembre 2016 20:03:29 CET Anders Kragh Barfod (andb) wrote: > Hi List. > > I'm trying to convert a CSV to PostgreSQL with ogr2ogr, but the CSV is > coming from an API: > > > http://api.statbank.dk/v1/data/FT/CSV?delimiter=Semicolon&HOVEDDELE=*&Tid=* > > I have tried following ogr2ogr: > > ogr2ogr -f PostgreSQL PG:"dbname=postgres host=localhost port=5432 > user=postgres password=xxx" > CSV:"/vsicurl/http://api.statbank.dk/v1/data/FT/CSV?delimiter=Semicolon&HOV > EDDELE=*&Tid=*" -nln FT -lco SEPARATOR=SEMICOLON > > But are getting: Unable to open data source.... > I can get it working if I download the CSV and use ogr2ogr, but would prefer > to fetch it straight from the API to reduce the steps in my script.
Anders, The server doesn't seem to support range GET requests, but I see this works if you use the /vsicurl_streaming/ virtual file system (and CSV reading is in streaming, so this matches well) ogrinfo -ro CSV:"/vsicurl_streaming/http://api.statbank.dk/v1/data/FT/CSV? delimiter=Semicolon&HOVEDDELE=*&Tid=*" -al -q Note that -lco SEPARATOR=SEMICOLON is useless. -lco stands for layer creation option, so this should be for the output driver, here PostgreSQL Even -- Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
