Dear Sir or Madam
I need to read an input file named S.txt which contains a column of data like below:
0.01
0.02
0.03
0.04
and then saved it in a list like dtlist
I wrote the below lines, but it just took the first row data (0.01)
please help me
My code is:
set dtlist " " ; # define the array
if [catch {open S.txt r} InFileID] {
puts "ERROR - cannot open S.txt" ; # open the S.txt file
}
lappend dtlist [gets $InFileID]
close $InFileID
puts "dtlist=$dtlist"
reading a .txt file in a list format
Moderators: silvia, selimgunay, Moderators
Re: reading a .txt file in a list format
the gets command reads only a line of data every time http://www.tcl.tk/man/tcl8.5/TclCmd/gets.htm
try the read command, or use a loop to read every line
try the read command, or use a loop to read every line
Re: reading a .txt file in a list format
Thanks i fixed that