小编Ted*_*ris的帖子

将csv写入来自DSX python 2.7 notebook的Ibm bluemix对​​象存储

我正在尝试从DSX Python笔记本中将pandas数据帧作为CSV写入Bluemix对​​象存储.我首先将数据帧保存为"本地"CSV文件.然后我有一个例程尝试将文件写入对象存储.我得到413响应 - 对象太大了.该文件只有大约3MB.这是我的代码,基于我在这里找到的JSON示例:http://datascience.ibm.com/blog/working-with-object-storage-in-data-science-experience-python-edition/

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  
Run Code Online (Sandbox Code Playgroud)

非常感谢任何帮助或指示.

data-science-experience dsx ibm-cloud

2
推荐指数
1
解决办法
1307
查看次数

标签 统计

data-science-experience ×1

dsx ×1

ibm-cloud ×1