Let's see...
First, your data are space delimited rather than comma delimited (as I assumed in my example). Fine. There are many ways to proceed here but I would use
regsub to change all occurrences of any number of spaces to commas:
regsub -all {\s+} $rw {,} rw
Now your data will look like:
[tt]var1,1value1,1value2, . . . ,1value100
var2,2value1,2value2, . . . ,2value100
var3,3value1,3value2, . . . ,3value100[/tt]
I'm still not clear as to what you do with the data, that is, how you use it inside
Opensees. Therefore, I can't say whether a 2-d array is the best way to store it. Assuming (as you suggest in your post) that, indeed, you want to build an array that will be 100x100, the only thing we need to do is get rid of the first element of each row (line), since that will be the variable name:
set elmlst [lreplace $elmslt 0 0]
If you want to be really cute, instead of the row index being a number from 0-99, it can be the variable name, itself, otherwise, I have no reason to change what I had before:
Code:
set fid [open <filename> r]; #assign a channel to the file
set rowslst [split [read $fid] \n]; #make a list of lines
close $fid
[s]set i 0[/s]
foreach rw $rowslst {
[red]regsub -all {\s+} $rw {,} rw[/red];#make rw comma-delimited
set elmlst [split $rw ,]; #make a list of elements on each line
set j 0
[red]set i [lindex $elmlst 0][/red];#make i = varname
[red]set elmlst [lreplace $elmslt 0 0][/red];#remove 0th element
foreach elm $elmlst {
set A($i,$j) $elm; # assuming your array is named "A"
incr j
}
[s]incr i[/s]
}
_________________
Bob Rashkin