问题
I am trying to read h5 file from AWS S3. I am getting the following errors using 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
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
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
回答1:
Your h5py version should work, but you'll need h5py version 2.9. See "file-like objects" here: http://docs.h5py.org/en/stable/high/file.html.
来源:https://stackoverflow.com/questions/51759237/read-h5-file-using-aws-s3-s3fs-boto3