Created
July 1, 2018 00:58
-
-
Save lloydw/e6efdd356af79704d88903934e85887a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib2 import urlopen | |
import csv | |
import os | |
import tempfile | |
def importUrl(url): | |
response = urlopen(url) | |
code = response.getcode() | |
if code != 200: | |
raise Exception('Invalid response', code) | |
return csv.DictReader(response) | |
def getSheetUrl(key, sheet): | |
return 'https://docs.google.com/spreadsheets/d/' + key + '/gviz/tq?tqx=out:csv&sheet=' + sheet | |
def importSheet(key, sheet): | |
return importUrl(getSheetUrl(key, sheet)) | |
# https://docs.google.com/spreadsheets/d/1vWhLZoCAjkaB16PG4ApgUD4mGUxXlED9JVJsFXLy07U/edit?usp=sharing | |
if __name__ == '__main__': | |
for row in importSheet('1vWhLZoCAjkaB16PG4ApgUD4mGUxXlED9JVJsFXLy07U', 'types'): | |
print(str(row)) | |
for row in importSheet('1vWhLZoCAjkaB16PG4ApgUD4mGUxXlED9JVJsFXLy07U', 'colors'): | |
print(str(row)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment