= 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 problem with my email program.
tee chwee liong
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 module
port, channel, lane, eyvt = line.split()
ValueError: need more than 2 values to unpack
the error is due to below line code:
...@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
list out all the Lane number? And if there is no -1, print PASS
tee chwee liong tc...@hotmail.com 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
line. how to make the line search at
line Port, Chnl, Lane, EyVt?
thanks
tcl76
Date: Mon, 10 Jan 2011 00:48:51 +1100
From: st...@pearwood.info
To: tutor@python.org
Subject: Re: [Tutor] Open a text file, read and print pattern matching
tee chwee liong wrote:
hi,
there is error
tee chwee liong tc...@hotmail.com wrote
File C:/Python25/myscript/log/readfile9.py, line 5, in module
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 =
...@btinternet.com
Date: Sun, 9 Jan 2011 14:07:39 +
Subject: Re: [Tutor] Open a text file, read and print pattern matching
tee chwee liong tc...@hotmail.com wrote
i got syntax error when running this line:
data = for line in open(filename) if not line.startswith(#)
Should
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
. 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 +
Subject: Re: [Tutor] Open a text file, read and print pattern matching
tee chwee liong tc...@hotmail.com wrote
File C:/Python25
'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 +
Subject: Re: [Tutor] Open a text file, read and print pattern matching
tee chwee liong tc
(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,
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
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
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
Tempt : 25
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.
15 matches
Mail list logo