You can query any public Google Sheet or CSV on the internet on the fly with the following syntax.
https://www.loom.com/share/e15ea6c32cce4f1e9798edf2e17cb69d
Get the Sheet ID from the URL
<aside> 💡 The spreadsheet needs to be public (i.e. “Anyone on the internet with this link can view”). Click “Share” in the top right to change this setting on your Sheet.
</aside>
Replace the ID (1XGCy0tY...
) in the snippet below
Use either CSVWithNames
if your sheet has headers or CSV
if it doesn’t
We suggest using CTE’s if you plan to join the data
It’s also a good idea to specify the range (e.g. &range=A:C
)
with sheet as (
select *
from
url('<https://docs.google.com/spreadsheets/d/1XGCy0tYU5YcEouO09_ErZIyqjA-VJ4pidLZmMmJkEdk/gviz/tq?tqx=out:csv&sheet=Sheet1&range=A:C>', CSVWithNames)
)
select * from sheet
with hn as (
select *
from
url('<https://storage.googleapis.com/luabase-public/hn.csv>', CSVWithNames)
)
select * from hn limit 20