Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在datalab中递归地从目录读取文件_Python_Google Cloud Storage_Google Cloud Datalab - Fatal编程技术网

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

Python 在datalab中递归地从目录读取文件,python,google-cloud-storage,google-cloud-datalab,Python,Google Cloud Storage,Google Cloud Datalab,我有要读取的dicom文件列表。我需要递归读取文件的代码。我试过这样的东西,但不起作用 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 dico

我有要读取的dicom文件列表。我需要递归读取文件的代码。我试过这样的东西,但不起作用

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
有关如何将GCS对象读入Python变量的示例,请参见此

本质上,您需要首先获取这些对象所在的bucket,然后迭代该bucket的对象并将其读入变量