Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading in data in rows and splitting to coloumn

Status
Not open for further replies.

andremincos

Technical User
Aug 15, 2014
3
0
0
ID
Hello there,

The program using TCL 8.3 and was write the code below;

##########################################
proc filtering {datalist} {
set a[a $datalist]
set b[b $datalist]
foreach item $datalist {
lappend calresult [list $item [expr {$a + $b}] ]
}
set result [lsort -decreasing -index 1 -real $calresult]

foreach item $calresult {
if {[lindex $item 1] > 1.5} {
lappend outputlist $item
set print [join $outputlist ", "]
}
}
return $print
}

set writevalues [open resulted.txt w]
set outputvalues [filtering $datalist]
puts $writevalues $outputvalues
##########################################

Base on script above the Resulted below;
123 17.7992234471, 110 15.8843066333, 79 11.317966539, 58.6 8.31302015439

How to change the result by rows like this;
1, 123, 17.7992234471
2, 110, 15.8843066333
3, 79, 11.317966539
4, 58.6, 8.31302015439

Appreciate your helps.

Thanks!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top