I have a large amount of RTF files where the only thing in them is an
image. I would like to extract them an save them as a png.
Eventually, I would like to also grab some text that is on the image.
I think PIL has something for this.
Does anyone have any suggestion on how to start this?
I am trying to output all the lines that start with a specific word.
It is a large output file (~14 Mb), but nothing that I thought would
be a problem.
for line in open('output.new'):
i_line = line.split()
if i_line:
if i_line[0] == "intrinsic":
print i_line
It does no
rrors being outputted?
>
> a cleaner way for reading the file:
>
> for line in open("output.new"):
> if line.startswith("intrinsic"):
> print line
>
>
> On Mon, Jun 22, 2009 at 2:16 PM, Bryan Fodness
> wrote:
>>
>> I am trying
I have a data file 'data1.dat',
*a* *b**c* *d*
1 0.10.110.111
2 0.20.220.222
3 0.30.330.333
9 0.90.990.999
and I want to be able to access the values of *b*, *c*, or *d* depending on
a value of *a*.
__
>
> Thank you both options work easily with my problem.
Bryan
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
The data file is larger than shown, and I was wondering if it would be
better to populate an array or create a dictionary. Which would be easier?
On 10/19/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> Bryan Fodness wrote:
> > I have a data file that I would like to
I have a data file that I would like to extract data from:
FS 1 2 3 4 5
1.5 1.000 1.000 1.000 1.000 1.000
2.0 0.985 0.994 0.997 0.996 0.996
2.5 0.967 0.976 0.981 0.981 0.982
3.0 0.949 0.958 0.965 0.966 0.967
3.5 0.925 0.937 0.945 0.948 0.
Here is my code.
dic2 = {}
for line in file('21Ex6MV_tmr.dat'):
d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
fs11, fs12, fs13, fs14, fs15, fs16, fs17, fs18, fs19,
fs20, fs21, fs22, fs23, fs24, fs25, fs26, fs27, fs28,
fs29, fs30, fs31, fs32, fs33, fs34, fs35, fs36, fs37,
it doesn't fix the problem, now it says there is a syntax error on the equal
sign.
On 10/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
>
> "Bryan Fodness" <[EMAIL PROTECTED]> wrote in
>
> >d, fs1, fs2, fs3, fs4, fs5, fs6, fs7, fs8, fs9, fs10,
&g
it works well if it is on the same line, but I would like to wrap it for
readability
On 10/21/07, Bryan Fodness <[EMAIL PROTECTED]> wrote:
>
> it doesn't fix the problem, now it says there is a syntax error on the
> equal sign.
>
> On 10/21/07, Alan Gauld
I want to get a variable name dependent on another variable. I have tried,
'fs' + str(int(round(unblockedFS))) for fs13
and I get an invalid literal. If I code in the fs13, everything works. Is
it possible to do this?
unblockedFS=13.4
for line in file('21Ex6MV_tmr.dat'):
d, fs1, fs2, fs
fs20, fs21, fs22, fs23, fs24, fs25,
fs26, fs27, fs28, fs29, fs30, fs31, fs32, fs33, fs34, fs35, fs36, fs37,
fs38, fs39, fs40 = line.split()
if float(d) == round(calc_depth):
print float('fs' + str(int(round(unblockedFS
On 10/22/07, Alan Gauld <[EMAIL PROTECTED]>
Thank you. This works well. I am still trying to figure out the pros and
cons of using an array, dictionary or list.
On 10/22/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> Bryan Fodness wrote:
> > Here is the actual snippet of code
> >
> >
> > calc_depth =
I have the following code, it keeps giving me a value of 1 for e.
for line in file('21Ex6MV_oaf.dat'):
oa, openoa, w15, w30, w45, w60 = line.split()
if (float(oa) == round(offaxis)) and (eff_depth < 10 and unblockedFS >
15):
e = float(openoa)
else:
e = 1
If I comment o
Is there a built-in function that will round to the nearest 0.5?
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
offaxis = (woffaxis * -1)
else:
woffaxis = 0
On 10/24/07, John Fouhy <[EMAIL PROTECTED]> wrote:
>
> On 25/10/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> > I have the following code, it keeps giving me a value of 1 for e.
> >
> > for line in file('
I would like to have my data in a format so that I can create a contour plot.
My data is in a file with a format, where there may be multiple fields
field = 1
1a 0
2a 0
3a 5
4a 5
5a 5
6a 5
7a 5
8a 5
9a 0
10a 0
1b 0
2b 0
3b 5
4b
figured out how I want to do that
yet.
On Nov 7, 2007 8:52 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bryan Fodness wrote:
> > I would like to have my data in a format so that I can create a contour
> > plot.
> >
> > My data is in a file with a format, w
ld' is not defined
On Nov 8, 2007 7:34 AM, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
>
> Kent Johnson wrote:
> > Bryan Fodness wrote:
> >> I would like to have my data in a format so that I can create a contour
> >> plot.
> >>
> >> My dat
Using the algorithm below, I get:
Traceback (most recent call last):
File "C:\Users\bryan\Documents\Yennes Medical
Physics\mlcShape\findvalue.py", line 49, in
file.next()
TypeError: descriptor 'next' of 'file' object needs an argument
And, it is true that I am trying to
I have tried,
f = open('TEST1.MLC')
fields = {}
for line in f:
the_line = line.split()
if the_line:
if the_line[0] == 'Field':
field = int(the_line[-1])
elif the_line[0] == 'Leaf':
fields[field] = the_line[-1]
which, sort of works, but it overwrites each value.
On Nov 12,
I see how to do it in a one-dimenstional array, but do not know the
syntax for the multi-dimensional case.
from numpy import *
a = zeros((60,40), int)
fields = {}
field = 10
fields[field] = '30A', 5
iy = int(fields[field][1])
ix = int(fields[field][0].rstrip('AB'))
for j in range(iy):
pu
Thank you. That works great!
On Nov 13, 2007 7:18 PM, Eike Welk <[EMAIL PROTECTED]> wrote:
> Hello Bryan!
>
> On Wednesday 14 November 2007 00:18, Bryan Fodness wrote:
> > I see how to do it in a one-dimenstional array, but do not know the
> > syntax for the multi-dime
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):
Fil
On Dec 5, 2007 4:16 PM, Jerry Hill <[EMAIL PROTECTED]> wrote:
> On Dec 5, 2007 4:01 PM, Mahesh N <[EMAIL PROTECTED]> wrote:
> > I dun understand the mistake. My aim is to accept an integer number. The
> > python lookup in IDLE asks for a string object but the interpreter
> returns
> > with the fol
I have a print statement in a for loop so I can watch the progress
for line in file(file):
the_line = line.split()
if the_line:
print ("Index = %.2f") %index
Is there a way that only one line will be output and the variable is updated
rather than one line for every index.
Thanks,
ndex = 0.000
Index = 0.400
Index = 0.800
Index = 1.000
Exit
On Dec 10, 2007 4:33 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bryan Fodness wrote:
> > I do want to overwrite the same line.
> >
> > I do not see a difference between using the \r and not using it.
>
&g
= 0.400 Index = 0.800 Index = 1.000
On Dec 10, 2007 4:48 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bryan Fodness wrote:
> > Here is the code.
> >
> > for line in file('test.txt'):
> > the_line = line.split()
> > if t
I ran it both in IDLE and Command Prompt
On Dec 10, 2007 5:02 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> How are you running the program?
>
> Bryan Fodness wrote:
> >
> > for line in file('test.txt'):
> > the_line = line.split()
> >
It works now.
Closed everything down and reopened.
Thanks.
On Dec 10, 2007 5:07 PM, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> I ran it both in IDLE and Command Prompt
>
>
> On Dec 10, 2007 5:02 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> > How are you r
I am trying to parse a DICOMRT file, which is a radiation therapy DICOM
file.
First, I get different outputs from the two methods below.
for line in file('file.dcm', 'rb'):
print line
inp = open('file.dcm', 'rb')
print inp.readlines()
Second, I have never tried to parse a binary file. I co
Thanks for the immediate response!
On Dec 12, 2007 5:57 PM, John Fouhy <[EMAIL PROTECTED]> wrote:
> On 13/12/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> > I am new to doing anything like this. I have looked at
> > http://www.leadtools.com/SDK/Medical/DICOM/ltdc1.
Just downloaded it and have not had a chance to check it out.
Thanks,
Bryan
On Dec 12, 2007 6:18 PM, Eric Brunson <[EMAIL PROTECTED]> wrote:
> Bryan Fodness wrote:
> > I am trying to parse a DICOMRT file, which is a radiation therapy
> > DICOM file.
>
> I'm a l
Is there an easy way that an input can be upper or lower case?
The file name is TEST.TXT, and I get.
-
Enter File (if not local, enter path):test.txt
Traceback (most recent call last):
File "test.py", line 52, in
I have a large file that has many lines like this,
SITE
I would like to identify the line by the tag (300a,0014) and then grab the
name (DoseReferenceStructureType) and value (SITE).
I would like to create a file that would have the structure,
DoseReferenceStructureType = Site
...
Haven't had a chance to look at this in a while.
On Wed, Dec 12, 2007 at 6:57 PM, John Fouhy <[EMAIL PROTECTED]> wrote:
> On 13/12/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> > I am new to doing anything like this. I have looked at
> > http://www.leadtools
Here is my program. I am trying to extract values from a binary file for
use in a calculation. I am having trouble with the logic. Everything goes
well until I use the parseSequence function. If there is only one sequence
I seem fine, but if there is a sequence within a sequence everything seem
the start_2 is supposed to be start
On Thu, Mar 27, 2008 at 5:42 PM, Bryan Fodness <[EMAIL PROTECTED]>
wrote:
> Thanks again,
>
> I can't seem to keep track of my start values when I break up the value
> variable into svalues. Do you think I should do this, or should I
Thanks again,
I can't seem to keep track of my start values when I break up the value
variable into svalues. Do you think I should do this, or should I have a
running count from the beginning of the file and keep track until the end?
I am trying to find \n0\x82\x00 and \n0\x84\x00 within the blo
On Thu, Mar 27, 2008 at 6:43 PM, bob gailer <[EMAIL PROTECTED]> wrote:
> Bryan Fodness wrote:
> > Thanks again,
>
> The problem is that parseSequence gets the length of the block, then, in
> effect, skips to the next block. That bypasses the sub-sequences you want.
&
Thanks again,
Still lost, even with watching the variables. I see that it kicks out of
the loop, but don't understand what I have done to cause this. I'm sorry
for repeated emails, but I have spent multiple days on this. I have added
another while loop that I think should work, but I can't seem
I have a data pair separated by a backslash. I didn' t think it would see
an end of line if the backslash was inside the quotes.
Can this be done? I don't have a choice in what the separator is.
>>> LeafJawPositions='-42.0001\29.8001'
>>> LeafJawPositions
'-42.0001\x029.8
Thanks everyone,
I was trying it this way.
x1, x2 = LeafJawPositions.split(r'\\')
On Wed, Apr 2, 2008 at 11:00 AM, Michael Connors <[EMAIL PROTECTED]>
wrote:
>
> >>> LeafJawPositions='-42.0001\29.8001'
> > >>> LeafJawPositions
> > '-42.0001\x029.8001'
> > >>>
I am trying to get values from an input file,
0.192
Custom
15
IN
but, when I check to see if they are equal it is not true.
f = open(infile, 'r')
s = f.readlines()
f.close()
Block = str(s[1])
Angle = float(s[2])
Position = str(s[3])
if Bloc
I am trying to figure out the best way to get external data.
Using the following data in a file
1
2
3
I have used,
fi = open(infile, 'r')
s = fi.readlines()
fi.close()
a = s[0]
b = s[1]
c = s[2]
but, if I have,
x = 1
y = 2
z = 3
I h
I am trying to read a long string of values separated by a backslash into an
array of known size.
Here is my attempt,
from numpy import *
ay, ax = 384, 512
a = zeros([ay, ax])
for line in open('out.out'):
data = line.split('\\')
k = 0
for i in range(ay):
for j in range(ax):
a[i, j
I tried posting this to numpy, but my posts never show up. So, I was hoping
someone here might be able to help me.
I have two arrays that are different sizes and i would like to be able
to add them for plotting.
If I have an array a and b,
[[1 2 3 4 5 6 7 8 9]
[1 2 3 4 5 6 7 8 9]
[1 2 3 4 5 6 7
Has anyone had a problem posting to either of these mailing lists. I am a
member and have sent a few posts to each of them over the last couple
months, but none of them show up in the list. I always receive a 'awaiting
moderator approval' email. I have sent an email to the owner about this,
but
when i execute my program without an argument i receive,
infile = sys.argv[1]
IndexError: list index out of range
is there a way that i could suppress this and add my own error code
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman
I have a string (column names) that I need to split.
D_H = 'D 5 10 15 20 25 30 35 40 D Upper D Lower'
I cannot do a simple list(D_H).split because the last two strings have a
space between them (D Upper and D Lower are two, not four labels).
Any suggestions?
_
I have a list of labels for a data file,
test = ['depth', '4', '6', '10', '15', '20', '30', '40', 'angle']
I would like to get the string of the first value that is greater than a
known value and the previous string.
If I have 15.8, I would like to get the index of '20' and '15'. I would
also l
I would like to check to see if the data files are good, readable, and
exist. I have checked to see if they exist, but their is a possibility that
the data file might be binary, and I would like to have a sys.exit for that
as well.
if not os.path.isfile(A_data) or not os.path.isfile(B_data)\
o
I am populating a dictionary from an input file, and would like to create an
error code if a string is sent to a variable that expects a float or int.
INPUT = {}
for line in open(infile):
input_line = line.split(' = ')
INPUT[input_line[0].strip()] = input_line[1].strip()
if INPUT.has_key(
i am filling a dictionary with a dictionary and my values for
isegment[field] are identical. i can't see where i am overwriting the
previous field values.
my data looks like
Field = aa1
Index = 0.0
Value = 0.0
...
...
Field = aa2
Index = 0.01
Value = 0.5
...
i would like to have something lik
I have a list in a text file that is in the python format.,
Positions = [2.5,2.8]
and would like to grab the values.
for line in file('list.txt'):
if line == Positions:
x1,x2=Positions
I know this does not work. Is there a direct way to get my x1 and x2
values.
Tha
I would like to use a try except to see if a value exists. But, when I use
the following, if a does not exist it exits. I understand why this does
this, but is there a way to get b,c, and d if a does not exist without using
a try except for every statement?
try:
fo.write("a = %s\n" %plan.a)
I am trying to change values in a file. The following code does not seem to
find the attribute.
def anonymize(obj, attr):
try:
obj.attr = 'Anonymize'
except AttributeError:
pass
for fname in os.listdir(os.curdir):
plan=ReadFile(fname)
anonymize(plan, 'Name')
It s
I would like to take a screenshot of my website without opening the browser
or importing extra packages. Is there a way to do this?
I would like to create a function like screenshot('
http://www.scatterworks.com";)
--
"The game of science can accurately be described as a never-ending insult to
h
58 matches
Mail list logo