I would know if it is possible to create a procedure that read some filea (they are files of output) and writes all of them in a single file...I've tried to do this but it doesen't work. In every file I would read there are 3 dates and they are called DefMAxpilastro# with # that goes from 50 to 69 and I want to write all in complessivo.txt
---procedure-----
for { set a 50 } { $a <= 69 } { incr a } {
set valori [open DefMAxpilastro$a.out "r"]
set nuovo [gets $valori]
set outfile [open complessivo.out w]
puts $outfile "$nuovo"
close DefMAxpilastro$a.out
}
close complessivo.txt
in this way it say CAN NOT FIND CHANNEL NAMED DefMAxpilastro50.out
but this is in the same directory so it would be find it...
instead if I try to write without for loop it read just the first value of the original file...
---test--------
set valori [open DefMAxpilastro53.out "r"]
set nuovo [gets $valori]
puts $nuovo
do you have any suggest?
thank you
Annalisa
read files and write
Moderators: silvia, selimgunay, Moderators
Re: read files and write
Try this:
for { set a 50 } { $a <= 69 } { incr a } {
set fName [format "DefMAxpilastro%02i.out" $a]
set valori [open $fName "r"]
set nuovo [gets $valori]
set outfile [open complessivo.out a]
puts $outfile "$nuovo"
close $valori
close $outfile
}
for { set a 50 } { $a <= 69 } { incr a } {
set fName [format "DefMAxpilastro%02i.out" $a]
set valori [open $fName "r"]
set nuovo [gets $valori]
set outfile [open complessivo.out a]
puts $outfile "$nuovo"
close $valori
close $outfile
}
Re: read files and write
thank you for your reply. In this way it works but it reads and writes only the first date of each files...instead in each files there are 3 dates. is it possible read each of them and write all?
thanks a lot
Annalisa
thanks a lot
Annalisa