I need to calculate the average of each column with a tcl script from a text file please help me
Frame Time Elec VdW Nonbond Total
0 0 -216.63 -16.0174 -232.647 -232.647
1 1 -196.786 -28.6093 -225.395 -225.395
2 2 -277.05 -23.924 -300.974 -300.974
3 3 -203.854 -30.2473 -234.101 -234.101
Once you start dealing with many columns, it gets easier to pull the whole file into memory. (This works well even for surprisingly large files.)
Now we can define a procedure to get the average of a column by name:
You'd call that like this: