在 watson studio 中使用云对象存储中的数据到 jupyter notebook

use the data from cloud object storage to jupyter noteboon in watson studio

我在 IBM 云中有一个云对象存储,里面有一个存储桶。存储桶中有 .wav 文件,我已经在 watson studio 中建立了与我的项目的连接,我也添加了数据资产。但我无法将数据插入 python jupyter notebook。我只在查找添加数据选项中插入凭据,而不是将数据作为流对象。几天前我曾经这样做过。我使用的是精简版,我的 mont 帐户免费试用有效期至 2019 年 8 月 12 日

该选项再次启用,同时您可以使用下面的代码片段将 .wav 文件读取为 StreamingBody

import types
import pandas as pd
from botocore.client import Config
import ibm_boto3

def __iter__(self): return 0
os_client= ibm_boto3.client(service_name='s3',
ibm_api_key_id='<IBM_API_KEY_ID>',
ibm_auth_endpoint="<IBM_AUTH_ENDPOINT>",
config=Config(signature_version='oauth'),
endpoint_url='<ENDPOINT>')

 # Your data file was loaded into a botocore.response.StreamingBody object.
 # Please read the documentation of ibm_boto3 and pandas to learn more about the possibilities to load the data.
 # ibm_boto3 documentation: https://ibm.github.io/ibm-cos-sdk-python/
 # pandas documentation: http://pandas.pydata.org/
 streaming_body_1 = os_client.get_object(Bucket='<BUCKET>', Key='myfile.wav')['Body']
 # add missing __iter__ method, so pandas accepts body as file-like object
if not hasattr(streaming_body_1, "__iter__"): streaming_body_1.__iter__ = types.MethodType( __iter__, streaming_body_1 )

您可以在此

中阅读有关将对象从 COS 读取到运行时的本地文件系统的更多详细信息