Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python importRows谷歌融合表API_Python_Csv_Http Post_Google Fusion Tables - Fatal编程技术网

Python importRows谷歌融合表API

Python importRows谷歌融合表API,python,csv,http-post,google-fusion-tables,Python,Csv,Http Post,Google Fusion Tables,我想使用Google fusion tables API将csv文件中的行导入fusion table,我读过,但我不明白如何在此处发布我的csv文件: 在python中如何将myFile.csv附加到请求 request = urllib2.Request("https://www.googleapis.com/fusiontables/v1/tables/---tableID---/import") request.get_method = lambda: 'POST' response =

我想使用Google fusion tables API将csv文件中的行导入fusion table,我读过,但我不明白如何在此处发布我的csv文件:

在python中如何将myFile.csv附加到请求

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

opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request('https://www.googleapis.com/fusiontables/v1/query?%s' % \
(urllib.urlencode({'access_token': access_token,
                   'sql': query})),
headers={'Content-Length':0})
request.get_method = lambda: 'POST' 
response = opener.open(request).read()
print response
这段代码使用简单的SQL查询将单行添加到fusion表中,但我需要添加100k行,因此根据需要,我必须使用该方法,而不是

谢谢。

根据此,导入行的正确URL为

https://www.googleapis.com/upload/fusiontables/v1/tables/tableId/import
将行导入表中

要将更多行导入现有表,请发送经过身份验证的POST 对以下URI的HTTP请求(注意下面URI中的上传):

必须在消息正文中提供行数据。行数据应该是 是CSV格式的数据,但可以指定其他分隔符

也许能帮上忙