Read a file with the load of a model in it
Dear All,
I have a file txt with the load that I need to apply to my model.
I would like to read it and assign, thru a routine, to my model (I know the point where I want apply each load).
I wrote the following code to read the txt file:
set fp [open "C:/Load.txt" r]
set file_data [read $fp]
close $fp
# Process data file
set data [split $file_data "\n"]
foreach line $data {
# I don't know how write here the list of variable
# one variable for each line of .txt file
}
Can someone help me?
thanks a lot in advance.
Fabio
0
Answers
-
"line" is the variable inside the foreach loop, so it can be referenced using $line and the first time through the loop it will be the first line, the second time it will be the second line. If instead of looping through the list of lines you want to grab a specific line you could just use "lindex $data 0" to get the first line and so on.
0 -
It works perfectly!
Thank you Ben!
I hope to be also useful sooner or later
Best regards,Fabio
0