I have three files which I need to merge into one. I need to read a unique id from the first file and then search the other two files for entries which match the unique id (they may or may not exist).
It works ok for the first record but goes haywire with subsequent records.
Here is a fragment of my code:
. . open all files first
set str1 [read $hrs]
set str2 [read $hry]
# Read file rz line by line
while {[gets $hrz linrz] >=0} {
set rzid [lindex $linrz 0]
# Look for entries in file rs
set inds [string first $rzid $str1]
incr inds
seek $hrs $inds start
set anyrs [gets $hrs rsdata]
if {$anyrs <=0} {
set rsapp $sep$sep
} else {
set rsapp [lindex $rsdata 0]$sep[lindex $rsdata 5]$sep[lindex $rsdata 6]
}
# Look for entries in file ry
set indy [string first $rzid $str2]
incr indy
seek $hry $indy start
set anyry [gets $hry rydata]
if {$anyry <=0} {
set ryapp $sep$sep
} else {
set ryapp [lindex $rydata 0]$sep[lindex $rydata 4]$sep[lindex $rydata 5]
}
}
I would appreciate any help.
Thanks,
Dave
It works ok for the first record but goes haywire with subsequent records.
Here is a fragment of my code:
. . open all files first
set str1 [read $hrs]
set str2 [read $hry]
# Read file rz line by line
while {[gets $hrz linrz] >=0} {
set rzid [lindex $linrz 0]
# Look for entries in file rs
set inds [string first $rzid $str1]
incr inds
seek $hrs $inds start
set anyrs [gets $hrs rsdata]
if {$anyrs <=0} {
set rsapp $sep$sep
} else {
set rsapp [lindex $rsdata 0]$sep[lindex $rsdata 5]$sep[lindex $rsdata 6]
}
# Look for entries in file ry
set indy [string first $rzid $str2]
incr indy
seek $hry $indy start
set anyry [gets $hry rydata]
if {$anyry <=0} {
set ryapp $sep$sep
} else {
set ryapp [lindex $rydata 0]$sep[lindex $rydata 4]$sep[lindex $rydata 5]
}
}
I would appreciate any help.
Thanks,
Dave