Skip to content

Instantly share code, notes, and snippets.

@vadimii
Created January 19, 2012 08:34
Show Gist options
  • Save vadimii/1638779 to your computer and use it in GitHub Desktop.
Save vadimii/1638779 to your computer and use it in GitHub Desktop.
Download data from Google Spreadsheets
import urllib2
DOC_PATH = 'https://docs.google.com/spreadsheet/pub?key=%s&output=txt'
GID_PARAM = '&single=true&gid=%s'
def load(docid, sheetid=None):
srcpath = DOC_PATH % docid
if sheetid != None: srcpath = srcpath + (GID_PARAM % sheetid)
src = urllib2.urlopen(srcpath)
return [l.split('\t') for l in src.readlines()]
if __name__ == '__main__':
testid = '0Atgd-n28fU3PdGlsMTdLRUFqR3JvbktmcWhqTFpSZmc'
print len(load(testid, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment