我正在尝试从亚马逊网络服务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:应为字符串、字节或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:应为字符串、字节或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 = fTypeError:应为字符串、字节或os.PathLike对象,而不是StreamingBody
发布于 2019-11-04 04:35:26
您的h5py版本应该可以工作,但您需要h5py版本2.9。请看这里的“类文件对象”:http://docs.h5py.org/en/stable/high/file.html。
https://stackoverflow.com/questions/51759237
复制相似问题