Dicom Files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Dicom Files (/thread-35251.html) |
Dicom Files - spillai - Oct-12-2021 Hi, I am using the following code to read one dicom file and write the info from that file to a text file. ds=dicom.dcmread("mw_test.dcm") file=open("mw_test.txt","w+") file.write(str(ds)) file.close()How can I expand this code for reading multiple dicom files from a directory and write the contents in a text fie with the same file name? RE: Dicom Files - Underscore - Oct-12-2021 using files like that is potentially dangerous because if an Exception happened before you close the file (like an user killing the process) it could break the entire file. for max security use the "with" statement RE: Dicom Files - menator01 - Oct-12-2021 Have a look at listdir |