Ignoring lines in a file TCL -
suppose have file1 few queries inside,
query 1 query 2 query 3
and have normal text file2 containing bunch of data
data 1 query 1 something data query 2 something query 3 something data1 continue no query data2 continue no query
how create loop such ignores lines containing queries file1 , prints lines without queries in file? in case these values gets printed
data1 continue no query data2 continue no query
i tried producing results using loop script made
storing queries ignored file1 $wlistitems
set openfile1 [open file1.txt r] while {[gets openfile1 data] > -1} { set wlist $data append wlistitems "{$wlist}\n" } close $openfile1
processing file2 print lines without ignored queries
set openfile2 [open file2.txt r] while {[gets $openfile2 data] > -1} { {set n 0} {$n < [llength $wlistitems]} {incr n} { if {[regexp -all "[lindex $wlistitems $n]" $data value]} { continue } puts $data } } close $openfile2
however, script not skip lines. instead prints out repeated data file2.
while {[gets $openfile2 data] > -1} { set found 0 {set n 0} {$n < [llength $wlistitems]} {incr n} { if {[regexp -all "[lindex $wlistitems $n]" $data value]} { set found 1 break } } if {!$found} { puts $data } }
Comments
Post a Comment