从S3中的.zip文件中提取文件

时间:2019-06-14 03:53:48

标签: python amazon-s3

在我的s3存储桶中,有多个zip文件(file1_2018-01-01file1_2018-01-02等),在这些zip文件中有多个.tsv文件。

使用Amazon SageMaker服务(Python 3实例),我想从例如.tsv中提取那些file_2019-01-01.zip文件并读取其内容。

我已经写了一个代码来获取所需的.zip文件名,但是无法继续进行操作。

ym = '2019-01-01' # Specifying the year and month
ext = '.zip' # Specifying the extension of the file
s3 = boto3.resource('s3')
bucket = s3.Bucket('my_bucket')
for obj in bucket.objects.all():
    key = obj.key
    if (ym in key) and (ext in key): 
        print(obj)

0 个答案:

没有答案
相关问题