如何使用python将数组一次插入Google电子表格中,不应逐个单元格上传数组。我的代码一次上传一个单元格太慢了。
#!/usr/bin/env python
import gdata.spreadsheet.service
from array import *
email = 'myemail@gmail.com'
password = 'mypassword'
spreadsheet_key = '1233...key...1234' # key param
worksheet_id = 'od6' # default
rows=[]
def main():
client = gdata.spreadsheet.service.SpreadsheetsService()
#client.debug = True
client.email = email
client.password = password
client.source = 'test client'
client.ProgrammaticLogin()
rows.append({'id':'0','title':'First'})
rows.append({'id':'1','title':'Second'})
for i in range(2,101):
rows.append({'id':str(i),'title':'First'})
for raw in rows:
try:
client.InsertRow(raw, spreadsheet_key, worksheet_id)
except Exception as e:
print e
return
if __name__ == '__main__':
main()