2016-04-28 7 views
0

私はGoogleシートにPythonで接続しようとしています。ここに私のコードスニペットがあります。GoogleのスプレッドシートにPythonでアクセスする

#!/usr/bin/python 

import time 
import gdata.spreadsheet.service 

email = '[email protected]' 
password = 'mypass' 
spreadsheet_key = '1k7XK1FzGcdLdQXs8hfLn6pdWcNZiesmW6Y5eOdxtDwE' 
worksheet_id = 'od6' 
spr_client = gdata.spreadsheet.service.SpreadsheetsService() 
spr_client.email = email 
spr_client.password = password 

try : 
    spr_client.ProgrammaticLogin() 
    print "Connected to spreadsheet" 
except Exception as e : 
    print "Error connecting to spreadsheet !!! ERROR : ", e 

dict = {} 
dict['date'] = time.strftime('%m/%d/%Y') 
dict['time'] = time.strftime('%H:%M:%S') 
print dict 

try : 
    entry = spr_client.InsertRow(dict, spreadsheet_key, worksheet_id) 
    print "Data entered successfully" 
except Exception as e : 
    print "Could not fill the spreadsheet !!! ERROR : ", e 

。まずは正しいユーザー名とパスワードで試してみましたが、私のコードはわずか30行ですが、それはエラーcElementTree.ParseError: mismatched tag: line 1254, column 4 です。

2.私は間違ったユーザー名とパスワードを試しました。それでもConnected to spreadsheetと表示されます。 spr_client.InsertRow(dict, spreadsheet_key, worksheet_id)を実行する上で

3.、私がthisのリンクから、このすべてを試してみましたCould not fill the spreadsheet ERROR : mismatched tag: line 1254, column 4

エラーを投げています。

このトップス - タービーの理由は何でしょうか。または私はどこかで間違っていますか?

答えて

1

gspread apiを見ると、はるかに使いやすくPythonic:https://github.com/burnash/gspreadです。私はgdata.spreadshetを使ってたくさんのtroubeを持っていましたが、もう一つ見つけました。

関連する問題