I try this,
f = open('TEST1.MLC')
fields = {}
for line in f:
if line.split()[0] == 'Field':
field = int(line.split()[-1])
elif line.split()[0] == 'Leaf':
fields[field] = line.split()[-1]
else:
line = f.next()
and get,
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
line.split()[0]
IndexError: list index out of range
I have attached my data file.
File Rev = G
Treatment = Dynamic Dose
Last Name = Fodness
First Name = Bryan
Patient ID = 0001
Number of Fields = 4
Number of Leaves = 120
Tolerance = 0.50
Field = 10
Index = 0.0000
Carriage Group = 1
Operator =
Collimator = 0.0
Leaf 1A = 0.00
Leaf 2A = 0.00
Leaf 3A = 0.00
Leaf 4A = 0.00
Leaf 5A = 0.00
Leaf 6A = 0.00
Leaf 7A = 0.00
Leaf 8A = 0.00
Leaf 9A = 0.00
Leaf 10A = 0.00
Leaf 11A = 0.00
Leaf 12A = 0.00
Leaf 13A = 0.00
Leaf 14A = 0.00
Leaf 15A = 0.00
Leaf 16A = 0.00
Leaf 17A = 0.00
Leaf 18A = 0.00
Leaf 19A = 0.00
Leaf 20A = 0.00
Leaf 21A = 5.00
Leaf 22A = 5.00
Leaf 23A = 5.00
Leaf 24A = 5.00
Leaf 25A = 5.00
Leaf 26A = 5.00
Leaf 27A = 5.00
Leaf 28A = 5.00
Leaf 29A = 5.00
Leaf 30A = 5.00
Leaf 31A = 5.00
Leaf 32A = 5.00
Leaf 33A = 5.00
Leaf 34A = 5.00
Leaf 35A = 5.00
Leaf 36A = 5.00
Leaf 37A = 5.00
Leaf 38A = 5.00
Leaf 39A = 5.00
Leaf 40A = 5.00
Leaf 41A = 0.00
Leaf 42A = 0.00
Leaf 43A = 0.00
Leaf 44A = 0.00
Leaf 45A = 0.00
Leaf 46A = 0.00
Leaf 47A = 0.00
Leaf 48A = 0.00
Leaf 49A = 0.00
Leaf 50A = 0.00
Leaf 51A = 0.00
Leaf 52A = 0.00
Leaf 53A = 0.00
Leaf 54A = 0.00
Leaf 55A = 0.00
Leaf 56A = 0.00
Leaf 57A = 0.00
Leaf 58A = 0.00
Leaf 59A = 0.00
Leaf 60A = 0.00
Leaf 1B = 0.00
Leaf 2B = 0.00
Leaf 3B = 0.00
Leaf 4B = 0.00
Leaf 5B = 0.00
Leaf 6B = 0.00
Leaf 7B = 0.00
Leaf 8B = 0.00
Leaf 9B = 0.00
Leaf 10B = 0.00
Leaf 11B = 0.00
Leaf 12B = 0.00
Leaf 13B = 0.00
Leaf 14B = 0.00
Leaf 15B = 0.00
Leaf 16B = 0.00
Leaf 17B = 0.00
Leaf 18B = 0.00
Leaf 19B = 0.00
Leaf 20B = 0.00
Leaf 21B = 5.00
Leaf 22B = 5.00
Leaf 23B = 5.00
Leaf 24B = 5.00
Leaf 25B = 5.00
Leaf 26B = 5.00
Leaf 27B = 5.00
Leaf 28B = 5.00
Leaf 29B = 5.00
Leaf 30B = 5.00
Leaf 31B = 5.00
Leaf 32B = 5.00
Leaf 33B = 5.00
Leaf 34B = 5.00
Leaf 35B = 5.00
Leaf 36B = 5.00
Leaf 37B = 5.00
Leaf 38B = 5.00
Leaf 39B = 5.00
Leaf 40B = 5.00
Leaf 41B = 0.00
Leaf 42B = 0.00
Leaf 43B = 0.00
Leaf 44B = 0.00
Leaf 45B = 0.00
Leaf 46B = 0.00
Leaf 47B = 0.00
Leaf 48B = 0.00
Leaf 49B = 0.00
Leaf 50B = 0.00
Leaf 51B = 0.00
Leaf 52B = 0.00
Leaf 53B = 0.00
Leaf 54B = 0.00
Leaf 55B = 0.00
Leaf 56B = 0.00
Leaf 57B = 0.00
Leaf 58B = 0.00
Leaf 59B = 0.00
Leaf 60B = 0.00
Note = 0
Shape = 4
500 500
500 -500
-500 -500
-500 500
Magnification = 1.00
Field = 8
Index = 0.4000
Carriage Group = 1
Operator =
Collimator = 0.0
Leaf 1A = 0.00
Leaf 2A = 0.00
Leaf 3A = 0.00
Leaf 4A = 0.00
Leaf 5A = 0.00
Leaf 6A = 0.00
Leaf 7A = 0.00
Leaf 8A = 0.00
Leaf 9A = 0.00
Leaf 10A = 0.00
Leaf 11A = 0.00
Leaf 12A = 0.00
Leaf 13A = 0.00
Leaf 14A = 0.00
Leaf 15A = 0.00
Leaf 16A = 0.00
Leaf 17A = 0.00
Leaf 18A = 0.00
Leaf 19A = 0.00
Leaf 20A = 0.00
Leaf 21A = 0.00
Leaf 22A = 0.00
Leaf 23A = 4.00
Leaf 24A = 4.00
Leaf 25A = 4.00
Leaf 26A = 4.00
Leaf 27A = 4.00
Leaf 28A = 4.00
Leaf 29A = 4.00
Leaf 30A = 4.00
Leaf 31A = 4.00
Leaf 32A = 4.00
Leaf 33A = 4.00
Leaf 34A = 4.00
Leaf 35A = 4.00
Leaf 36A = 4.00
Leaf 37A = 4.00
Leaf 38A = 4.00
Leaf 39A = 0.00
Leaf 40A = 0.00
Leaf 41A = 0.00
Leaf 42A = 0.00
Leaf 43A = 0.00
Leaf 44A = 0.00
Leaf 45A = 0.00
Leaf 46A = 0.00
Leaf 47A = 0.00
Leaf 48A = 0.00
Leaf 49A = 0.00
Leaf 50A = 0.00
Leaf 51A = 0.00
Leaf 52A = 0.00
Leaf 53A = 0.00
Leaf 54A = 0.00
Leaf 55A = 0.00
Leaf 56A = 0.00
Leaf 57A = 0.00
Leaf 58A = 0.00
Leaf 59A = 0.00
Leaf 60A = 0.00
Leaf 1B = 0.00
Leaf 2B = 0.00
Leaf 3B = 0.00
Leaf 4B = 0.00
Leaf 5B = 0.00
Leaf 6B = 0.00
Leaf 7B = 0.00
Leaf 8B = 0.00
Leaf 9B = 0.00
Leaf 10B = 0.00
Leaf 11B = 0.00
Leaf 12B = 0.00
Leaf 13B = 0.00
Leaf 14B = 0.00
Leaf 15B = 0.00
Leaf 16B = 0.00
Leaf 17B = 0.00
Leaf 18B = 0.00
Leaf 19B = 0.00
Leaf 20B = 0.00
Leaf 21B = 0.00
Leaf 22B = 0.00
Leaf 23B = 4.00
Leaf 24B = 4.00
Leaf 25B = 4.00
Leaf 26B = 4.00
Leaf 27B = 4.00
Leaf 28B = 4.00
Leaf 29B = 4.00
Leaf 30B = 4.00
Leaf 31B = 4.00
Leaf 32B = 4.00
Leaf 33B = 4.00
Leaf 34B = 4.00
Leaf 35B = 4.00
Leaf 36B = 4.00
Leaf 37B = 4.00
Leaf 38B = 4.00
Leaf 39B = 0.00
Leaf 40B = 0.00
Leaf 41B = 0.00
Leaf 42B = 0.00
Leaf 43B = 0.00
Leaf 44B = 0.00
Leaf 45B = 0.00
Leaf 46B = 0.00
Leaf 47B = 0.00
Leaf 48B = 0.00
Leaf 49B = 0.00
Leaf 50B = 0.00
Leaf 51B = 0.00
Leaf 52B = 0.00
Leaf 53B = 0.00
Leaf 54B = 0.00
Leaf 55B = 0.00
Leaf 56B = 0.00
Leaf 57B = 0.00
Leaf 58B = 0.00
Leaf 59B = 0.00
Leaf 60B = 0.00
Note = 0
Shape = 4
400 400
400 -400
-400 -400
-400 400
Magnification = 1.00
Field = 4
Index = 0.8000
Carriage Group = 1
Operator =
Collimator = 0.0
Leaf 1A = 0.00
Leaf 2A = 0.00
Leaf 3A = 0.00
Leaf 4A = 0.00
Leaf 5A = 0.00
Leaf 6A = 0.00
Leaf 7A = 0.00
Leaf 8A = 0.00
Leaf 9A = 0.00
Leaf 10A = 0.00
Leaf 11A = 0.00
Leaf 12A = 0.00
Leaf 13A = 0.00
Leaf 14A = 0.00
Leaf 15A = 0.00
Leaf 16A = 0.00
Leaf 17A = 0.00
Leaf 18A = 0.00
Leaf 19A = 0.00
Leaf 20A = 0.00
Leaf 21A = 0.00
Leaf 22A = 0.00
Leaf 23A = 0.00
Leaf 24A = 0.00
Leaf 25A = 0.00
Leaf 26A = 0.00
Leaf 27A = 2.00
Leaf 28A = 2.00
Leaf 29A = 2.00
Leaf 30A = 2.00
Leaf 31A = 2.00
Leaf 32A = 2.00
Leaf 33A = 2.00
Leaf 34A = 2.00
Leaf 35A = 0.00
Leaf 36A = 0.00
Leaf 37A = 0.00
Leaf 38A = 0.00
Leaf 39A = 0.00
Leaf 40A = 0.00
Leaf 41A = 0.00
Leaf 42A = 0.00
Leaf 43A = 0.00
Leaf 44A = 0.00
Leaf 45A = 0.00
Leaf 46A = 0.00
Leaf 47A = 0.00
Leaf 48A = 0.00
Leaf 49A = 0.00
Leaf 50A = 0.00
Leaf 51A = 0.00
Leaf 52A = 0.00
Leaf 53A = 0.00
Leaf 54A = 0.00
Leaf 55A = 0.00
Leaf 56A = 0.00
Leaf 57A = 0.00
Leaf 58A = 0.00
Leaf 59A = 0.00
Leaf 60A = 0.00
Leaf 1B = 0.00
Leaf 2B = 0.00
Leaf 3B = 0.00
Leaf 4B = 0.00
Leaf 5B = 0.00
Leaf 6B = 0.00
Leaf 7B = 0.00
Leaf 8B = 0.00
Leaf 9B = 0.00
Leaf 10B = 0.00
Leaf 11B = 0.00
Leaf 12B = 0.00
Leaf 13B = 0.00
Leaf 14B = 0.00
Leaf 15B = 0.00
Leaf 16B = 0.00
Leaf 17B = 0.00
Leaf 18B = 0.00
Leaf 19B = 0.00
Leaf 20B = 0.00
Leaf 21B = 0.00
Leaf 22B = 0.00
Leaf 23B = 0.00
Leaf 24B = 0.00
Leaf 25B = 0.00
Leaf 26B = 0.00
Leaf 27B = 2.00
Leaf 28B = 2.00
Leaf 29B = 2.00
Leaf 30B = 2.00
Leaf 31B = 2.00
Leaf 32B = 2.00
Leaf 33B = 2.00
Leaf 34B = 2.00
Leaf 35B = 0.00
Leaf 36B = 0.00
Leaf 37B = 0.00
Leaf 38B = 0.00
Leaf 39B = 0.00
Leaf 40B = 0.00
Leaf 41B = 0.00
Leaf 42B = 0.00
Leaf 43B = 0.00
Leaf 44B = 0.00
Leaf 45B = 0.00
Leaf 46B = 0.00
Leaf 47B = 0.00
Leaf 48B = 0.00
Leaf 49B = 0.00
Leaf 50B = 0.00
Leaf 51B = 0.00
Leaf 52B = 0.00
Leaf 53B = 0.00
Leaf 54B = 0.00
Leaf 55B = 0.00
Leaf 56B = 0.00
Leaf 57B = 0.00
Leaf 58B = 0.00
Leaf 59B = 0.00
Leaf 60B = 0.00
Note = 0
Shape = 4
200 200
200 -200
-200 -200
-200 200
Magnification = 1.00
Field = 1
Index = 1.0000
Carriage Group = 1
Operator =
Collimator = 0.0
Leaf 1A = 0.00
Leaf 2A = 0.00
Leaf 3A = 0.00
Leaf 4A = 0.00
Leaf 5A = 0.00
Leaf 6A = 0.00
Leaf 7A = 0.00
Leaf 8A = 0.00
Leaf 9A = 0.00
Leaf 10A = 0.00
Leaf 11A = 0.00
Leaf 12A = 0.00
Leaf 13A = 0.00
Leaf 14A = 0.00
Leaf 15A = 0.00
Leaf 16A = 0.00
Leaf 17A = 0.00
Leaf 18A = 0.00
Leaf 19A = 0.00
Leaf 20A = 0.00
Leaf 21A = 0.00
Leaf 22A = 0.00
Leaf 23A = 0.00
Leaf 24A = 0.00
Leaf 25A = 0.00
Leaf 26A = 0.00
Leaf 27A = 0.00
Leaf 28A = 0.00
Leaf 29A = 0.00
Leaf 30A = 0.50
Leaf 31A = 0.50
Leaf 32A = 0.00
Leaf 33A = 0.00
Leaf 34A = 0.00
Leaf 35A = 0.00
Leaf 36A = 0.00
Leaf 37A = 0.00
Leaf 38A = 0.00
Leaf 39A = 0.00
Leaf 40A = 0.00
Leaf 41A = 0.00
Leaf 42A = 0.00
Leaf 43A = 0.00
Leaf 44A = 0.00
Leaf 45A = 0.00
Leaf 46A = 0.00
Leaf 47A = 0.00
Leaf 48A = 0.00
Leaf 49A = 0.00
Leaf 50A = 0.00
Leaf 51A = 0.00
Leaf 52A = 0.00
Leaf 53A = 0.00
Leaf 54A = 0.00
Leaf 55A = 0.00
Leaf 56A = 0.00
Leaf 57A = 0.00
Leaf 58A = 0.00
Leaf 59A = 0.00
Leaf 60A = 0.00
Leaf 1B = 0.00
Leaf 2B = 0.00
Leaf 3B = 0.00
Leaf 4B = 0.00
Leaf 5B = 0.00
Leaf 6B = 0.00
Leaf 7B = 0.00
Leaf 8B = 0.00
Leaf 9B = 0.00
Leaf 10B = 0.00
Leaf 11B = 0.00
Leaf 12B = 0.00
Leaf 13B = 0.00
Leaf 14B = 0.00
Leaf 15B = 0.00
Leaf 16B = 0.00
Leaf 17B = 0.00
Leaf 18B = 0.00
Leaf 19B = 0.00
Leaf 20B = 0.00
Leaf 21B = 0.00
Leaf 22B = 0.00
Leaf 23B = 0.00
Leaf 24B = 0.00
Leaf 25B = 0.00
Leaf 26B = 0.00
Leaf 27B = 0.00
Leaf 28B = 0.00
Leaf 29B = 0.00
Leaf 30B = 0.50
Leaf 31B = 0.50
Leaf 32B = 0.00
Leaf 33B = 0.00
Leaf 34B = 0.00
Leaf 35B = 0.00
Leaf 36B = 0.00
Leaf 37B = 0.00
Leaf 38B = 0.00
Leaf 39B = 0.00
Leaf 40B = 0.00
Leaf 41B = 0.00
Leaf 42B = 0.00
Leaf 43B = 0.00
Leaf 44B = 0.00
Leaf 45B = 0.00
Leaf 46B = 0.00
Leaf 47B = 0.00
Leaf 48B = 0.00
Leaf 49B = 0.00
Leaf 50B = 0.00
Leaf 51B = 0.00
Leaf 52B = 0.00
Leaf 53B = 0.00
Leaf 54B = 0.00
Leaf 55B = 0.00
Leaf 56B = 0.00
Leaf 57B = 0.00
Leaf 58B = 0.00
Leaf 59B = 0.00
Leaf 60B = 0.00
Note = 0
Shape = 4
50 50
50 -50
-50 -50
-50 50
Magnification = 1.00
CRC = B4DC
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor