File: quartiles.tcl

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (38 lines) | stat: -rw-r--r-- 766 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
proc main {} {
    lassign $::argv csv

    set csv [open $csv r]	; gets $csv	;# open and strip header

    lassign {Inf 0 Inf 0} tmin tmax wmin wmax
    
    while {![eof $csv]} {
	lassign [split [gets $csv] ,] code t w
	if {$code eq {}} continue
	lappend tl $t
	lappend wl $w
    }

    set tl [lsort -real -increasing $tl]
    set wl [lsort -real -increasing $wl]

    puts [join {Quart Type Width} ,]

    set nt [llength $tl] ; incr nt -1
    set nw [llength $wl] ; incr nw -1
    
    for {set q 0} {$q <= 100} {incr q} {
	set it [expr { ($nt * $q) / 100 }]
	set iw [expr { ($nw * $q) / 100 }]

	#puts stderr $q/$it/$iw/[llength $tl]/[llength $wl]
	
	set qt [lindex $tl $it]
	set qw [lindex $tl $iw]

	puts [join [list $q $qt $qw] ,]
    }

    return
}

main