W
wang frank
Hi,
I am a new user on Python and I really love it.
I have a big text file with each line like:
label 3
teststart 5
endtest 100
newrun 2345
I opened the file by uu=open('test.txt','r') and then read the data as
xx=uu.readlines()
In xx, it contains the list of each line. I want to find a spcefic labels
and read the data. Currently, I
do this by
for ss in xx:
zz=ss.split( )
if zz[0] = endtest:
index=zz[1]
Since the file is big and I need find more lables, this code runs slowly.
Are there anyway to speed up the process? I thought to convert the data xx
from list to a dictionay, so I can get the index quickly based on the
label. Can I do that effeciently?
Thanks
Frank
_________________________________________________________________
$B%a%C%;%s%8%c!<$*M'C#>R2p%W%l%<%s%HBh(B2$BCF3+;O!*%i%9%Y%,%9N99T%W%l%<%s%H(B
http://campaign.live.jp/dizon/
I am a new user on Python and I really love it.
I have a big text file with each line like:
label 3
teststart 5
endtest 100
newrun 2345
I opened the file by uu=open('test.txt','r') and then read the data as
xx=uu.readlines()
In xx, it contains the list of each line. I want to find a spcefic labels
and read the data. Currently, I
do this by
for ss in xx:
zz=ss.split( )
if zz[0] = endtest:
index=zz[1]
Since the file is big and I need find more lables, this code runs slowly.
Are there anyway to speed up the process? I thought to convert the data xx
from list to a dictionay, so I can get the index quickly based on the
label. Can I do that effeciently?
Thanks
Frank
_________________________________________________________________
$B%a%C%;%s%8%c!<$*M'C#>R2p%W%l%<%s%HBh(B2$BCF3+;O!*%i%9%Y%,%9N99T%W%l%<%s%H(B
http://campaign.live.jp/dizon/