Re: Comparing two files line by line
- From: Bruce Hartweg <bruce-news@xxxxxxxxxx>
- Date: Fri, 14 Jul 2006 10:23:57 -0500
Niv wrote:
I have a stimulus file with 3 digit hex numbers and a results file alsoIf the files are small, it is easier to read the whole thing and then split
with 3 digit hex numbers (The rtesults file has already gone through
one tcl script to get the results into the same format as the
stimulus).
The results file may be longer than the stimulus file due to default
results once stimulus has expired (This is for a VHDL testbench).
The files are not too long, probably < 100 lines.
So how do I compare the files line by line, until stimulus finished,
then check any extra lines in results are default?
The only way I see is to read each file line by line into two separate
lists & then work on the lists.
I don't think the while { [gets $f1 inline1] >= 0}
{ will work, as how do I get the data-line from $f2?
Is there a simpler way?
TIA, Niv.
by lines.
set buf1 [read $f1]
set buf2 [read $f2]
foreach l1 [split $buf1 "\n"] l2 [split $buf2 "\n"] {
if {$l1 eq $l2} {
puts "Lines the same"
} else if {$l1 eq "" && $l2 eq $default} {
puts "default output"
} else {
puts "something else"
}
}
Bruce
.
- References:
- Comparing two files line by line
- From: Niv
- Comparing two files line by line
- Prev by Date: Re: shouldn't http::formatQuery be slightly modified
- Next by Date: Re: Comparing two files line by line
- Previous by thread: Comparing two files line by line
- Next by thread: Re: Comparing two files line by line
- Index(es):
Relevant Pages
|