importRows谷歌融合表API

2024-04-20 06:59:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用googlefusion tables API将csv文件中的行导入到fusion表中,我读了this reference,但我不知道如何在这里发布csv文件:https://www.googleapis.com/upload/fusiontables/v1/tables/---tableId---/import

我该如何连接我的文件.csv在python中请求?在

request = urllib2.Request("https://www.googleapis.com/fusiontables/v1/tables/---tableID---/import")
request.get_method = lambda: 'POST'
response = opener.open(request).read()

我已经拥有:

^{pr2}$

这段代码使用简单的SQL查询将单行添加到fusion表中,但是我需要添加100k行,因此根据this reference我必须使用importRows方法,而不是SQL insert statements。在

谢谢。在


Tags: 文件csvhttpsimportcomtablessqlrequest
1条回答
网友
1楼 · 发布于 2024-04-20 06:59:12

根据这个documentation,导入行的正确URL是

https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import

Importing rows into a table

To import more rows into an existing table, send an authenticated POST HTTP request to the following URI (note the upload in the URI below):

https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import

You must supply the row data in the message body. The row data should be CSV formatted data, though you may specify alternative delimiters.

或许this example能有所帮助。在

相关问题 更多 >