I have 20,000 PosixPath, each one pointing at a different .dcm object. I need to read .dcm objects one by one. Here is my code so far:
from pathlib import Path
import glob
import dicom
data = Path('/data')
path_to_dcm_objects = list(data.glob('**/*.dcm'))
for i in len(path_to_dcm_objects):
record = dicom.read_file(path_to_dcm_objects[i])
I get an error when I want to read a .dcm file using its PosixPath:
AttributeError: 'PosixPath' object has no attribute 'read'
Any help would be appreciated.