0
Google Spreadsheetにデータを挿入するPythonのコードがあります。どのようにデータを挿入する行を選択できますか?例: 温度、湿度、圧力、および実際の日付の3つの変数があります。それらをE1からH1の行にインストールする必要がありますか?特定の行に挿入するGoogleSpreadsheet - Python
import time
import httplib2
# Do OAuth2 stuff to create credentials object
from oauth2client.file import Storage
from oauth2client.client import flow_from_clientsecrets
#from oauth2client.tools import tools
import math
import tools
import getopt
import sys
import string
import datetime
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())
# Use it within old gdata
import gdata.spreadsheet.service
import gdata.service
client = gdata.spreadsheet.service.SpreadsheetsService(
additional_headers={'Authorization' : 'Bearer %s' % credentials.access_token})
#public example
spreadsheet_key = my_spreadsheet_key'
entry = client.GetSpreadsheetsFeed(spreadsheet_key)
print entry.title
temp=20
pressure = 1000
humidity = 40
# # Prepare the dictionary to write
dict = {}
dict['datetime'] = time.strftime("%Y-%m-%d %H:%M:%S")
dict['ctemp'] = str(temp)
dict['pressure'] = str(pressure)
dict['humidity'] = str(humidity)
rangeName = 'E1:H1'
#What should I write here?
#print dict
#entry = client.InsertRow(dict, spreadsheet_key, 'od6')
#if isinstance(entry, gdata.spreadsheet.SpreadsheetsList):
#print "Insert row succeeded."
#else:
# print "Insert row failed."