메뉴 건너뛰기

infra

[GData] python 으로 spreadsheet 에 업데이트

suritam92013.11.04 08:21조회 수 1576댓글 0

    • 글자 크기
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import time
import gdata.spreadsheet
import gdata.spreadsheet.service
import gdata.spreadsheets.data

def _CellsUpdateAction(row,col,inputValue,key,wksht_id):
    entry = spr_client.UpdateCell(row=row, col=col, inputValue=inputValue,
            key=key, wksht_id=wksht_id)
    #if isinstance(entry, gdata.spreadsheet.SpreadsheetsCell):
        #print 'Updated!'

email = '이메일'
password = '패스워드'
weight = '180'
# Find this value in the url with 'key=XXX' and copy XXX below
spreadsheet_key = '키번호'
# All spreadsheets have worksheets. I think worksheet #1 by default always
# has a value of worksheet_id 는 gid값 하고 관련이 없어 보인다, 암튼, 기본은 od6인데, od4, od8 로 임의 입력하며 원하는 시트를 찾아서 입력한다.
worksheet_id = 'od6'

spr_client = gdata.spreadsheet.service.SpreadsheetsService()
spr_client.email = email
spr_client.password = password
spr_client.source = 'Example Spreadsheet Writing Application'
spr_client.ProgrammaticLogin()

# Prepare the dictionary to write
#dict = {}
#dict['date'] = time.strftime('%m/%d/%Y')
#dict['time'] = time.strftime('%H:%M:%S')
#dict['weight'] = weight
#uu = u'비고'
no = int(sys.argv[1])
keyword = unicode(sys.argv[2],'utf-8')
fr = unicode(sys.argv[3],'utf-8')
comment = unicode(sys.argv[4],'utf-8')
freq = sys.argv[5]#if type is integer, do not int() function
recommend = unicode(sys.argv[6],'utf-8')
use = sys.argv[7]#if type is integer, do not int() function
reguser = unicode(sys.argv[8],'utf-8')
regip = unicode(sys.argv[9],'utf-8')
regdate = unicode(sys.argv[10],'utf-8')
#print sys.argv[3]
i = no + 6
#_CellsUpdateAction(i,2,'1',spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,3,keyword,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,4,fr,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,5,comment,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,6,freq,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,7,recommend,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,8,use,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,9,reguser,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,10,regip,spreadsheet_key,worksheet_id)
_CellsUpdateAction(i,11,regdate,spreadsheet_key,worksheet_id)


print 1
#entry = spr_client.InsertRow(dict, spreadsheet_key, worksheet_id)
#if isinstance(entry, gdata.spreadsheet.SpreadsheetsList):
#  print "Insert row succeeded."
#else:
#  print "update row failed."
#feed = spr_client.GetSpreadsheetsFeed()

suritam9 (비회원)
    • 글자 크기
[ipin] 인증 우회나 변조 막기 (by suritam9) [WIN] DisableCMD 로 쉘 접속 막기, 사용자 그룹 추가 삭제 (by suritam9)

댓글 달기

첨부 (0)
위로