【发布时间】:2019-08-08 05:04:51
【问题描述】:
我的 Blob 存储中有一个包含大约 200k 图像的容器。我想用 Python 编写一个脚本,将 20k 的这些图像批量复制到名为 imageset1、imageset2、...、imageset20 之类的新容器中(最后一个容器中的图像少于 20k,这很好)。
到目前为止,我有以下内容:
from azure.storage.blob import BlockBlobService
from io import BytesIO from shutil
import copyfileobj
with BytesIO() as input_blob:
with BytesIO() as output_blob:
block_blob_service = BlockBlobService(account_name='my_account_name', account_key='my_account_key')
# Download as a stream
block_blob_service.get_blob_to_stream('mycontainer', 'myinputfilename', input_blob)
# Here is where I want to chunk up the container contents into batches of 20k
# Then I want to write the above to a set of new containers using, I think, something like this...
block_blob_service.create_blob_from_stream('mycontainer', 'myoutputfilename', output_blob)
这是将容器的内容分块并将结果写入新容器,我不知道该怎么做。有人可以帮忙吗?
【问题讨论】:
-
所有发布的都是程序描述。请参阅 Jon Skeet 的 How to Ask 帮助页面和 The perfect question 博客文章。我们无法确定您想从我们这里得到什么。请edit您的帖子包含一个我们可以回答的有效问题。提醒:通过访问help center,确保您知道这里的主题是什么;要求我们为您编写程序、建议和外部链接都是题外话。
-
是否有任何模式可以对这些图像进行分类?按名称还是按时间带等?
-
彼得,不,没有。图片格式如下:RBG4906_1.jpg, RBG4906_2.jpg(所以有两张略有不同的图片,后缀为1或2)。图片名称中的数字不是连续的,所以据我所知没有模式。
-
@JassiL 所以你只想将它们移动到具有平均数字大小的不同容器中。对吗?
标签: python-3.x azure azure-blob-storage