]> Creatis software - gdcm.git/blob - gdcmPython/demo/PrintHeader.py
7648b483b3b1b06b460bad49a9ebd9a559c45fdd
[gdcm.git] / gdcmPython / demo / PrintHeader.py
1 from gdcmPython import *
2 import sys
3
4 ### Get filename from command line or default it
5 try:
6    FileName = sys.argv[1]
7 except IndexError:
8    FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
9
10 #if not os.path.isfile(FileName):
11 #   print "Cannot open file ", FileName
12 #   sys.exit()
13
14 # On debugging purposes uncomment the next line
15 #s = raw_input("Hit any key in this window to exit")
16
17 ### Build the header element list
18 toRead = gdcmHeader(FileName)
19 if not toRead.IsReadable():
20    print "The ", FileName, " file is not readable with gdcm. Sorry."
21    sys.exit()
22
23 print "##############################################################"
24 print "### Display all the elements and their respective values"
25 print "## found in the ", FileName, " file."
26 print "##############################################################"
27 ValDict = toRead.GetEntry()
28 for key in ValDict.keys():
29         print "[%s] = [%s]" %(key, ValDict[key])