Aditya Matturi
Aditya Matturi

Reputation: 119

read files from a directory recursively in datalab

I am having list of dicom files to be read. 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

Upvotes: 0

Views: 491

Answers (1)

yelsayed
yelsayed

Reputation: 5532

See this sample notebook for an example how to read GCS objects into Python variables.

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.

Upvotes: 1

Related Questions