【问题标题】:Read h5 file using AWS S3 s3fs/boto3使用 AWS S3 s3fs/boto3 读取 h5 文件
【发布时间】:2018-08-09 05:09:42
【问题描述】:

我正在尝试从 AWS S3 读取 h5 文件。使用 s3fs/boto3 时出现以下错误。你能帮我吗?谢谢!

import s3fs

fs = s3fs.S3FileSystem(anon=False, key='key', secret='secret')

with fs.open('file', mode='rb') as f:
     h5 = pd.read_hdf(f)

TypeError:预期的 str、字节或 os.PathLike 对象,而不是 S3File

fs = s3fs.S3FileSystem(anon=False, key='key', secret='secret')
with fs.open('file', mode='rb') as f:
    hf = h5py.File(f)

TypeError:预期的 str、字节或 os.PathLike 对象,而不是 S3File

client = boto3.client('s3',aws_access_key_id='key',aws_secret_access_key='secret')
result = client.get_object(Bucket='bucket', Key='file')
with h5py.File(result['Body'], 'r') as f:
    data = f

TypeError:预期的 str、bytes 或 os.PathLike 对象,而不是 StreamingBody

【问题讨论】:

    标签: python amazon-s3 boto3 h5py


    【解决方案1】:

    您的 h5py 版本应该可以工作,但您需要 h5py 版本 2.9。请参阅此处的“类文件对象”:http://docs.h5py.org/en/stable/high/file.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-02
      • 2021-10-18
      • 2017-04-21
      • 2017-09-29
      • 1970-01-01
      • 2019-08-21
      • 2022-09-28
      • 2021-05-22
      相关资源
      最近更新 更多