(Don't top-post. You keep putting your responses out of order.)
On 01/-10/-28163 02:59 PM, tee chwee liong wrote:
i modified the code to be:
fname = "sampledata.txt"
pattern = "-1"
failed = False
for line in open(fname):
data=line.split()
if len(data)==4:
port, channel, lane
failure=True
print 'Lane', search.split()[2], 'Fail'
if not failure:
print "All Lanes Pass"
thanks
tcl76
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:14:17 +0000
> Subject: Re: [Tutor] Open a
teral for int() with base 10: 'EyVt'
pls help to advise. don't understand int() with base 10 mean?
thanks
tcl76
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:14:17 +0000
> Subject: Re: [Tutor] Open a text file, read and prin
> thanks this solve the error but running the code produces another error ie
>index out of range.
> if line[3] == pattern:
> IndexError: list index out of range
So you need to check that there are at least 4 elements in the line before
trying to access it. Or else catch the exception (see my
t; From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:07:39 +0000
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
>
> "tee chwee liong" wrote
>
> > i got syntax error when running this line:
> > data = for line in o
"tee chwee liong" wrote
File "C:/Python25/myscript/log/readfile9.py", line 5, in
port, channel, lane, eyvt = line.split()
ValueError: need more than 2 values to unpack
So you need to ensure that you unpack when you have the right
number of fields:
either:
data = line.split()
if len(dat
#x27;, '3', '-1']
['0', '1', '4', '-1']
['0', '1', '5', '10']
['+++++++++++++++++']
['Time:', '20s']
that's why port, channel, lane, eyv
"tee chwee liong" wrote
i got syntax error when running this line:
data = for line in open(filename) if not line.startswith("#")
Should be:
data = [ line for line in open(filename) if not line.startswith("#") ]
Notice the extra line at the beginning and the fact that it is
surrounded by []
-0500
> From: kb1...@aim.com
> To: tutor@python.org
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
> On 01/09/2011 01:25 AM, tee chwee liong wrote:
> > hi,
> >
> > i have a sampledata as below. Pls refer to output, if found -1, how to
&
tee chwee liong wrote:
hi,
there is error when running the code:
Traceback (most recent call last):
File "C:/Python25/myscript/log/readfile9.py", line 5, in
port, channel, lane, eyvt = line.split()
ValueError: need more than 2 values to unpack
the error is due to below line code:
port, cha
port, channel, lane, eyvt = line.split()
pls advise.
thanks
tcl76
> Date: Sun, 9 Jan 2011 17:44:58 +1100
> From: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
> Please excuse the double post, I had a pr
Please excuse the double post, I had a problem with my email program.
tee chwee liong wrote:
hi,
i have a sampledata as below. Pls refer to output, if found -1, how to list out
all the Lane number? And if there is no -1, print PASS. My code is as below
section.
Code###
On 01/09/2011 01:25 AM, tee chwee liong wrote:
> hi,
>
> i have a sampledata as below. Pls refer to output, if found -1, how to
> list out all the Lane number? And if there is no -1, print PASS. My code
> is as below section.
>
> thanks
> tcl76
>
> sampledata
> Platform: PC
> T
tee chwee liong wrote:
hi,
i have a sampledata as below. Pls refer to output, if found -1, how to list out
all the Lane number? And if there is no -1, print PASS. My code is as below
section.
thanks
tcl76
sampledata
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
++
14 matches
Mail list logo