Python 在datalab中递归地从目录读取文件
我有要读取的dicom文件列表。我需要递归读取文件的代码。我试过这样的东西,但不起作用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
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的对象并将其读入变量