AzureML列出大量文件
我在 AzureML 笔记本中有一个目录,其中有 300k 个文件,需要列出它们的名称。 下面的方法有效,但需要 1.5 小时才能执行:
from os import listdir
from os.path import isfile, join
mypath = "./temp/"
docsOnDisk = [f for f in listdir(mypath) if isfile(join(mypath, f))]
快速列出这些文件的 azure 方法是什么? (笔记本和此目录都在 FileShare 中)。
我也知道下面的方法会带来一些好处,但这仍然不是做到这一点的天蓝色方法。
docsOnDisk = [f.name for f in scandir(mypath) ] # shall be 2-20x faster
I have directory in AzureML notebook in which I have 300k files and need to list their names.
Approach below works but takes 1.5h to execute:
from os import listdir
from os.path import isfile, join
mypath = "./temp/"
docsOnDisk = [f for f in listdir(mypath) if isfile(join(mypath, f))]
What is the azure way to quickly list those files? (both notebook and this directory is in FileShare).
I am also aware that the approach below will give some gain, but still it is not the azure way to do this.
docsOnDisk = [f.name for f in scandir(mypath) ] # shall be 2-20x faster
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 glob 模块和过滤方法而不是列表理解。
glob 应该只给出现有文件。不需要使用 isfile() 来验证它们。但如果您需要尝试一下,那么您可以使用过滤方法而不是列表理解。要跳过验证,您可以注释最后一行。
Try using glob module and filter method instead of list comprehension.
glob should give only existing files. Its not needed to verify them by using isfile(). But still if you need to try it out then you can use filter method instead of list comprehension. To skip verification, you can comment last line.