1

How do I read a .csv file from a URL with an API call, including key, in QGIS 3?

I've tried creating a .vrt file as outlined here

I've tried the solutions presented here

If I'm doing everything correctly, then the differences between these examples and my case are that my URL is https and that my URL has an API call following the .csv extension.

eg: https://developer.nrel.gov/api/alt-fuel-stations/v1.csv?fuel_type=HY&state=CA&api_key=G3tUr0wNk33&format=csv

The .vrt file I assembled:

<OGRVRTDataSource>
<OGRVRTLayer name="test">
    <SrcDataSource relativeToVRT="0">/vsicurl/https://developer.nrel.gov/api/alt-fuel-stations/v1.csv?fuel_type=HY&state=CA&api_key=G3tUr0wNk33&format=csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
</OGRVRTLayer></OGRVRTDataSource>
  • The solution though in the questions referenced mention http and https, so that's probably not the issue. – nmtoken Apr 24 at 12:51
  • Can you edit the question to show the VRT you created to do this? – nmtoken Apr 24 at 12:53
  • @nmtoken I have edited the question to show the VRT file – oglj Apr 24 at 19:25
  • One thing that you must correct is to use XML escaped special characters in the VRT file. Thus this is at least more correct as data source <SrcDataSource relativeToVRT="0">/vsicurl/https://developer.nrel.gov/api/alt-fuel-stations/v1.csv?fuel_type=HY&amp;state=CA&amp;api_key=G3tUr0wNk33&amp;format=csv</SrcDataSource>. Unfortunately that did not make the vrt to work for me. Continue from this and use ogrinfo for testing ogrinfo apitest.vrt --debug on. – user30184 Apr 24 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.