How to import raw CSV from github

Hi all,
if I import this CSV

https://github.com/italia/covid19-opendata-vaccini/raw/master/dati/somministrazioni-vaccini-latest.csv

using

d3 = require("d3-fetch@1")
urla = "https://github.com/italia/covid19-opendata-vaccini/raw/master/dati/somministrazioni-vaccini-latest.csv"
data = d3.csv(urla)

I have this error data = TypeError: Failed to fetch.

If I use jsdelivr URL[1], for the same file I have non error.

What’s the way to import a raw github csv URL in observarble?

Thank you

[1] https://cdn.jsdelivr.net/gh/italia/covid19-opendata-vaccini@master/dati/somministrazioni-vaccini-summary-latest.csv

It looks like GitHub disallows fetching data directly from repositories (through its CORS policy), but allows it for gists. I uploaded the data to a new gist; here’s an example that loads it:

Edit: The URL you provided actually redirects to a raw.githubusercontent.com URL, which does allow CORS requests. I updated the example.

5 Likes

If you open https://github.com/italia/covid19-opendata-vaccini/raw/master/dati/somministrazioni-vaccini-latest.csv in a browser, it will redirect to https://raw.githubusercontent.com/italia/covid19-opendata-vaccini/master/dati/somministrazioni-vaccini-latest.csv, which can be used in observable because the Access-Control-Allow-Origin header is set to *

Edit: didn’t see @yurivish’s Edit

3 Likes

Thank you @severo and @yurivish

1 Like