 <p>The following code snippet is example of how to use a chronological list of array keys, in order to print out array contents in order. This is then used to make an array with two of every element.</p> <pre><code>#!/usr/bin/tclsh proc add_element {array_name key value} { upvar $array_name aa if { ![info exists aa($key)] } { set aa($key) $value lappend aa() $key } } add_element names 1 Jane add_element names 2 Tom add_element names 3 Elisabeth add_element names 4 Ted add_element names 5 Sally foreach e $names() { add_element morenames $e $names($e) add_element morenames $[expr $e + 1 ] $names($e) } foreach e $morenames() { puts $morenames($e) } </code></pre> <p>In order to solve your problem you would generate new arrays for atten and power with double element as per the above example. You would then generate your other arrays using a function similar to the example above, unless they already are returned ordered when iterating through them.</p> <p>You would then iterate through on of the other arrays, say newTime, using something similar to the snippet below:</p> <pre><code> set rows [array size newTime] for {set row 1} {$row &lt;= $rows} {incr row} { $cells Item $row "A" $newatten($row) $cells Item $row "B" $newpower($row) $cells Item $row "C" $newbandwidth($row) $cells Item $row "C" $newTime($row) } </code></pre> <p>The following code snippet is an example of how to remap numeric keys of a TCL Array (Associative array or HashMap).</p> <pre><code>#!/usr/bin/tclsh set names(1) Jane set names(2) Tom set names(3) Elisabeth set names(4) Robert set names(5) Julia set names(6) Victoria foreach n [array names names] { puts $n puts $names($n) } puts "-------------" foreach n [array names names] { set newnames([expr $n -1]) $names($n) } foreach n [array names newnames] { puts $n puts $newnames($n) } </code></pre> <p>This isn't sufficient to do what you want. </p> <p>You would have to do this and then remove <code>unset</code> the first element and add <code>set</code> a last element. </p> <p>You haven't specified in your question what your last element would be.</p> <p>If you are using non numeric keys, e.g string keys then you would have to give those keys some concept of order, whether by mapping them to numeric keys or using some other method.</p> <p>Note that TCL arrays don't return things in order in a foreach loop unless you tell them to.</p> <p>TCL lists are better suited to that, as demostrated by.</p> <pre><code>#!/usr/bin/tclsh set i 0 foreach j "a b c" { puts "$j is item number $i in list x" incr i } </code></pre> <p>You also haven't specified what data structures you want to convert to or whether you just want to write the input to screen (using <code>puts</code>) or to file.</p> <p>E.g Whether you would to generate any of the folllowing data structures for your table ? </p> <ul> <li>A TCL array of TCL arrays (Hashmap of Hashmap)</li> <li>A List of Lists</li> <li>A TCL array of Lists</li> <li>A List of TCL Arrays (List of Hashmap)</li> </ul> <p>For further information see:</p> <ul> <li><a href="http://wiki.tcl.tk/532" rel="nofollow">Arrays Page TCL Wiki</a></li> <li><a href="http://wiki.tcl.tk/440" rel="nofollow">List Page TCL Wiki</a></li> <li><a href="http://www.tcl.tk/man/tcl/tutorial/Tcl22.html" rel="nofollow">Associative Arrays Page TCL Tutorial</a></li> <li><a href="http://www.tcl.tk/man/tcl/tutorial/Tcl14.html" rel="nofollow">List Page TCL Tutorial</a></li> </ul>