要用 python 讀取儲存在 S3 中的 gzip 檔案資料
使用的過程中,boto3 有用 s3_client 也有用 s3 resource 取得 S3 object 的方式,需要找時間再研究這兩者的差異

code sample

def load_gzip(client, bucket, key): response = client.get_object(Bucket=bucket, Key=key) content = response['Body'].read() with gzip.GzipFile(fileobj=io.BytesIO(content), mode='rb') as fh: file_content = fh.read() return file_content.decode("utf-8")

讀多個 S3 檔案的方式

Reference

Comments

2022-05-09