#!/usr/bin/env tclsh ## -*- tcl -*- # Generate HTML table from CSV data package require csv package require cmdline package require report package require struct # ---------------------------------------------------- # csv2html ?-sep sepchar? file... # # Argument processing and checks. set sepChar , set title "Title" set usage "Usage: $argv0 ?-sep sepchar? ?-title string? file..." while {[set ok [cmdline::getopt argv {sep.arg title.arg} opt val]] > 0} { #puts stderr "= $opt $val" switch -exact -- $opt { sep {set sepChar $val} title {set title $val} } } if {($ok < 0) || ([llength $argv] < 1)} { #puts stderr "A >>$ok<< >>[llength $argv]<<" puts stderr $usage exit -1 } set files $argv if {[llength $files] == 0} { set files - } # ---------------------------------------------------- # Actual processing, uses the following information from the # commandline: # # files - name of the files to read # indices - preprocessed indices # sepChar - separator character ::report::defstyle html {} { set c [columns] set cl $c ; incr cl -1 data set "