简体   繁体   English

使用 AWS S3 s3fs/boto3 读取 h5 文件

[英]Read h5 file using AWS S3 s3fs/boto3

I am trying to read h5 file from AWS S3.我正在尝试从 AWS S3 读取 h5 文件。 I am getting the following errors using s3fs/boto3.我在使用 s3fs/boto3 时遇到以下错误。 Can you help?你能帮我吗? Thanks!谢谢!

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: expected str, bytes or os.PathLike object, not S3File类型错误:预期的 str、bytes 或 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: expected str, bytes or os.PathLike object, not S3File类型错误:预期的 str、bytes 或 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: expected str, bytes or os.PathLike object, not StreamingBody类型错误:预期的 str、bytes 或 os.PathLike 对象,而不是 StreamingBody

Your h5py version should work, but you'll need h5py version 2.9.您的 h5py 版本应该可以工作,但您需要 h5py 2.9 版。 See "file-like objects" here: http://docs.h5py.org/en/stable/high/file.html .请参阅此处的“类文件对象”: http : //docs.h5py.org/en/stable/high/file.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM