我正在嘗試從DSX Python筆記本將一個熊貓數據框編寫爲CSV到Bluemix Object Storage。我首先將數據框保存到「本地」CSV文件。然後我有一個例程,試圖將文件寫入對象存儲。我得到一個413響應 - 對象太大。該文件只有大約3MB。這裏是我的代碼的基礎上,JSON例如我發現這裏:http://datascience.ibm.com/blog/working-with-object-storage-in-data-science-experience-python-edition/編寫csv到DSX Python 2.7筆記本的Ibm bluemix對象存儲器
import requests
def put_file(credentials, local_file_name):
"""This function writes file content to Object Storage V3 """
url1 = ''.join(['https://identity.open.softlayer.com', '/v3/auth/tokens'])
data = {'auth': {'identity': {'methods': ['password'],
'password': {'user': {'name': credentials['name'],'domain': {'id': credentials['domain']},
'password': credentials['password']}}}}}
headers = {'Content-Type': 'text/csv'}
with open(local_file_name, 'rb') as f:
resp1 = requests.post(url=url1, data=f, headers=headers)
return resp1
任何幫助或指針是非常讚賞。
你可以接受解決你的問題的答案,而不是僅僅用一個評論來承認它:-) –