You can query any public Google Sheet or CSV on the internet on the fly with the following syntax.



  1. 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.



  2. Replace the ID (1XGCy0tY...) in the snippet below

  3. Use either CSVWithNames if your sheet has headers or CSV if it doesn’t

  4. We suggest using CTE’s if you plan to join the data

  5. It’s also a good idea to specify the range (e.g. &range=A:C)

with sheet as (
	select * 
	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 * 
	url('<https://storage.googleapis.com/luabase-public/hn.csv>', CSVWithNames)

select * from hn limit 20