Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import httplib2
- from oauth2client.file import Storage
- from oauth2client.client import flow_from_clientsecrets
- from oauth2client.tools import tools
- import math
- import getopt
- import sys
- import string
- import datetime
- import gdata.spreadsheet.service
- import gdata.service
- storage = Storage("creds.dat")
- credentials = storage.get()
- if credentials is None or credentials.invalid:
- flags = tools.argparser.parse_args(args=[])
- flow = flow_from_clientsecrets("client_secret.json", scope=["https://spreadsheets.google.com/feeds"])
- credentials = tools.run_flow(flow, storage, flags)
- if credentials.access_token_expired:
- credentials.refresh(httplib2.Http())
- client = gdata.spreadsheet.service.SpreadsheetsService(
- additional_headers={'Authorization' : 'Bearer %s' % credentials.access_token})
- spreadsheet_key = '1Vv-HJGcPfAjQF-VEgfO675gVEkxuWTsYnLH-Hgt8neo'
- entry = client.GetSpreadsheetsFeed(spreadsheet_key)
- print entry.title
- for i in range(25):
- val = i
- dict = {}
- dict['date'] = time.strftime('%m/%d/%Y')
- dict['time'] = time.strftime('%H:%M:%S')
- dict['value'] = str(val)
- print dict
- entry = client.InsertRow(dict, spreadsheet_key, 'od6')
- if isinstance(entry, gdata.spreadsheet.SpreadsheetsList):
- print "Insert row succeeded."
- else:
- print "Insert row failed."
Add Comment
Please, Sign In to add comment