On 28/05/12 23:15, Brendan Dornan wrote:
Hi, I’d like to eliminate the no data fields in this XML file, since
Tableau, the graphing software doesn’t allow this. What would be the
easiest way to approach this? I’m a complete neophyte, having gone
through the first 15 chapters of the “Think Like a
Hi, I'd like to eliminate the no data fields in this XML file, since
Tableau, the graphing software doesn't allow this. What would be the
easiest way to approach this? I'm a complete neophyte, having gone through
the first 15 chapters of the "Think Like a Computer Scientist." Long ways to
go and a
ot;Alan Gauld" <[EMAIL PROTECTED]>
Cc:
Sent: Monday, November 12, 2007 2:43 PM
Subject: Re: [Tutor] manipulating data
>I try this,
>
> f = open('TEST1.MLC')
>
> fields = {}
>
> for line in f:
>if line.split()[0] == 'Field':
>fie
Bryan Fodness wrote:
> 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()
>
>
On Monday November 12, 2007, Bryan Fodness wrote:
>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[fie
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
"Bryan Fodness" <[EMAIL PROTECTED]>
> 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, b
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,
The lesson here is not to try to do two things at once...
> file.next()
> TypeError: descriptor 'next' of 'file' object needs an argument
OK, My algorithm was meant to be pseudo code so file was
not intended to be taken literally, its just a marker for an open
file object.
> And, it
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
Alan Gauld wrote:
> "Bryan Fodness" <[EMAIL PROTECTED]> wrote in
>
>> fields = {}
>> for line in open('data.txt') :
>>if line : ## You shouldn't need this.
>> if line.split()[0] == 'field' :
>> field = int(line.split()[-1])
>> else :
>> fields[field] = tuple(l
Brian,
> if line.split()[0] == 'Field':
>field = int(line.split()[-1])
>
> IndexError: list index out of range
You have blank lines in the file, when you try to call split
on an empty string you get an empty list so trying to
index any element will result in an Index error.
That's
"Bryan Fodness" <[EMAIL PROTECTED]> wrote in
> fields = {}
> for line in open('data.txt') :
>if line : ## You shouldn't need this.
> if line.split()[0] == 'field' :
> field = int(line.split()[-1])
> else :
> fields[field] = tuple(line.split())
>
> fields[field
Using,
fields = {}
for line in open('data.txt') :
if line :
if line.split()[0] == 'field' :
field = int(line.split()[-1])
else :
fields[field] = tuple(line.split())
I get,
fields[field] = tuple(line.split())
NameError: name 'field' is not defined
On Nov
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 data is in a file with a format, where there may be multiple fields
>>
>> field = 1
>>
>> 1a 0
>
> If your data is really this regular, it is pretty easy to parse.
I also have some information at the beginning of the file and between
each field. Is there a way to get the info at the beginning and tell
it once it sees Leaf 1A to read the values for the next 120 and then
repeat until there are no more Fields.
File Rev = G
Treatment = Dynamic Dose
Last Name =
Bryan Fodness wrote:
> I also have some information at the beginning of the file and between
> each field. Is there a way to get the info at the beginning and tell
> it once it sees Leaf 1A to read the values for the next 120 and then
> repeat until there are no more Fields.
This should be a pret
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, where there may be multiple fields
>
> field = 1
>
> 1a0
If your data is really this regular, it is pretty easy to parse. A
useful technique is to ac
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
19 matches
Mail list logo