Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Created January 13, 2014 22:28
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 joyrexus/8409340 to your computer and use it in GitHub Desktop.
Save joyrexus/8409340 to your computer and use it in GitHub Desktop.
Get google spreadsheet data

Quick demonstration of how to retrieve google spreadsheet data in CSV format.

In order to access a particular spreadsheet you need to both "share" and "publish" it.

That is, open the Google Doc you want to access and under the File menu ...

  • select Share and select either "Publish as a web page" or "Anyone with the link".

  • select Publish to the web and click "Start publishing".

get = require 'request'
# keys of a few published spreadsheets
key =
demo: 'o13394135408524254648.240766968415752635' # google demo
leap: '0AmrUeNvUdKG1dFlJbUdVRmVCbTNjcVFPUTFRdi1Kb3c' # leap motion data
test: '0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE'
params = "?key=#{key.test}&single=true&gid=0&output=csv"
url = 'https://docs.google.com/spreadsheet/pub' + params
done = (err, res, body) ->
if not err and res.statusCode is 200
console.log body.split(',').join("\t")
else
console.error res.statusCode, err
get url, done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment