Skip to content

Instantly share code, notes, and snippets.

@crazy4groovy
Last active April 1, 2021 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazy4groovy/82bada49c86a092e6b4d04ac25b65928 to your computer and use it in GitHub Desktop.
Save crazy4groovy/82bada49c86a092e6b4d04ac25b65928 to your computer and use it in GitHub Desktop.
Read a public-readable Google Speadsheet as a CSV or JSON (JavaScript)
// see: https://andregarzia.com/2018/11/reading-google-sheets-data-from-livecode.html
async function readSheet(key, sheetName = 'Sheet1', format = 'csv' /* 'json' */) {
const url = `https://docs.google.com/spreadsheets/d/${key}/gviz/tq?tqx=out:${format}&sheet=${sheetName}`
return fetch(url).then(r => r.text())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment