Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dicom Files
#1
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?
Yoriz write Oct-12-2021, 02:15 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
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

666+666*666/666-666
Reply
#3
Have a look at listdir
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dicom image reading smitha 2 3,240 Feb-09-2020, 03:12 AM
Last Post: Larz60+
  DICOM Structure Files jcozzi1 1 2,274 Jul-20-2019, 07:40 AM
Last Post: scidam
  Trying to invert DICOM image with Python 3.6 newmanf 1 5,729 Feb-28-2018, 08:49 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020