简体   繁体   English

在datalab中递归地从目录中读取文件

[英]read files from a directory recursively in datalab

I am having list of dicom files to be read. 我有要读取的dicom文件列表。 I need the code to read files recursively. 我需要代码来递归读取文件。 I tried something like this but it is not working. 我尝试了类似的方法,但是没有用。

import google.datalab.storage as storage
path = [o.key for o in storage.Objects('msadata', '', '')]
for i in range(len(path)):
  image="gs://msadata/"+str(path[i])
  %gcs read --object image --variable dicom_file

See this sample notebook for an example how to read GCS objects into Python variables. 有关如何将GCS对象读入Python变量的示例,请参见此样本笔记本

Essentially, you need to first get the bucket those objects are in, then iterate on that bucket's objects and read them into your variable. 本质上,您需要首先获取这些对象所在的存储桶,然后迭代该存储桶的对象并将它们读入变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM