Re: file: extract data after finding string match
- From: Bruce Hartweg <doNOTuse@xxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 09:29:38 -0500
Niv wrote:
I currently read a set of (similar) files, containing only addresses
as @000000 etc, or byte data in successive lines. I copy the files to
a list and then strip out all data in the list(s) up to and including
a particular address, @300000.
The lists are later compared to a different list for exact match of
byte data.
However, is there a better way to read the file into the list(s) so I
don't have to replace the unwanted list data with null data?
file example:
@000000
F1
C4
54
34
65
@100000
43
56
76
87
@300000
F1
49
DE
E5
i.e. I want all the byte data from after the @300000 and nothing else
n my list(s).
set fd [open $myFileName]
set contents [read $fd]
close $fd
if {[regexp {@300000\s*(.*)} $contents fullmatch bytesIwant]} {
set myList [split $bytesIwant \n]
} else {
puts "Couldn't find address marker"
}
Bruce
.
- References:
- Prev by Date: file: extract data after finding string match
- Next by Date: Re: TCL Yahoo Finance's Whereabouts
- Previous by thread: file: extract data after finding string match
- Index(es):
Relevant Pages
|