【发布时间】:2022-11-06 00:57:06
【问题描述】:
我想在 for 循环中从 AWS S3 存储桶中读取镶木地板文件。
这是我的代码(不起作用):
session = boto3.Session(
aws_access_key_id=key,
aws_secret_access_key=secret,
region_name=region_name)
s3 = session.resource('s3')
bucket = s3.Bucket(bucket_name)
for obj in bucket.objects.filter(Prefix=folder_path):
response = obj.get()
df = pd.read_parquet(response['Body'])
# some data processing
它打印以下错误:
ValueError: I/O operation on closed file 和 ArrowInvalid: Called Open() on an uninitialized FileSource。
我应该在这里解决什么问题?
【问题讨论】:
-
that doesn't work是什么意思? -
它不读取文件。
-
它是否给出任何具体错误?
-
没什么...请注意,对于 CSV 文件,它确实有效。
-
抱歉,现在我可以看到一个错误。它打印:
ValueError: I/O operation on closed file和ArrowInvalid: Called Open() on an uninitialized FileSource。
标签: python pandas amazon-web-services amazon-s3 boto3