2012-12-10 139 views
3

有沒有人使用過融合表API的函數importRows()? 作爲下面的API參考, https://developers.google.com/fusiontables/docs/v1/reference/table/importRows 我必須在請求正文中提供CSV數據。 但是,我應該爲HTML身體完全做什麼?融合表importrows

我的代碼:

http = getAuthorizedHttp() 

DISCOVERYURL = 'https://www.googleapis.com/discovery/v1/apis/{api}/{apiVersion}/rest' 

ftable = build('fusiontables', 'v1', discoveryServiceUrl=DISCOVERYURL, http=http) 

body = create_ft(CSVFILE,"title here") # the function to load csv file and create the table with columns from csv file. 
result = ftable.table().insert(body=body).execute() 
print result["tableId"] # good, I have got the id for new created table 

# I have no idea how to go on here.. 
f = ftable.table().importRows(tableId=result["tableId"]) 
f.body = ????????????? 
f.execute() 

回答

1

我定這樣的問題:

media = http.MediaFileUpload('example.csv', mimetype='application/octet-stream', resumable=True) 
request = service.table().importRows(media_body=media, tableId='1cowubQ0vj_H9q3owo1vLM_gMyavvbuoNmRQaYiZV').execute()