I am trying to read an excel file that is stored in my project data assets into my notebook on ibm watson studio and am retrieving the following error:
AttributeError: 'StreamingBody' object has no attribute 'seek'
Here is the code I used from the included option menu (api key id was edited out on purpose):
import types
import pandas as pd
from botocore.client import Config
import ibm_boto3
def __iter__(self): return 0
# @hidden_cell
# The following code accesses a file in your IBM Cloud Object Storage. It includes your credentials.
# You might want to remove those credentials before you share the notebook.
client_7de401550a6447db83336f61dc6f7a36 = ibm_boto3.client(service_name='s3',
ibm_api_key_id='....',
ibm_auth_endpoint="https://iam.cloud.ibm.com/oidc/token",
config=Config(signature_version='oauth'),
endpoint_url='https://s3-api.us-geo.objectstorage.service.networklayer.com')
body = client_7de401550a6447db83336f61dc6f7a36.get_object(Bucket='courseracapstone-donotdelete-pr-gulobge2viwrrq',Key='business-licences.xlsx')['Body']
# add missing __iter__ method, so pandas accepts body as file-like object
if not hasattr(body, "__iter__"): body.__iter__ = types.MethodType( __iter__, body )
df_data_0 = pd.read_excel(body)
df_data_0.head()