Created
October 7, 2017 18:52
-
-
Save bennettscience/454e64aa5ce74c70277bd9b77a5609e8 to your computer and use it in GitHub Desktop.
Download and sort a Google Sheet as JSON
This file contains 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
#! /usr/local/bin/python | |
import json, requests | |
# Your Google Sheet as JSON feed | |
url = "https://spreadsheets.google.com/feeds/list/YOUR_KEY_HERE/od6/public/values?alt=json" | |
# Get the data and store it as a dictionary you can sort | |
r = requests.get(url) | |
logs = r.json() | |
list = [] | |
# Turn the whole feed into an iterable list | |
for log in logs['feed']['entry']: | |
list.append((log['gsx$timestamp']['$t'], log['gsx$action']['$t'])) | |
# Show the last 5 items only | |
for item in list[-5:]: | |
print ('%s %s' % (item[0], item[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment