Report is a [tcllib] command for report generation. Documentation can be found at http://tcllib.sourceforge.net/doc/report.html ---- Has anyone done anything ''simple'' with this command? I'm having problems figuring where to start. [How to wrap cell contents when using tcllib struct::matrix and report ] ---- ====== package require csv package require report package require struct ... open a channel to a a CSV file, with default separator (comma) struct::matrix::matrix m # The following code extracts the number of columns from the file # and initializes the matrix to that number of columns. if {[gets $channel line] < 0} { # here, you either continue, return with an error, or take some other action for when the file being read is empty } set data [::csv::split $line $sepChar] m add columns [llength $data] m add row $data csv::read2matrix $channel m report::report r [m columns] ; # (*) r printmatrix2channel m stdout ====== This should print the CSV file to stdout, auto-formatted so that each column is wide enough to hold the longest value of that column. No visual frills like header, footer or column separators. ---- For output as HTML table add ====== ::report::defstyle html {} { set c [columns] set cl $c ; incr cl -1 data set " [split [string repeat " " $cl] ""] " for {set col 0} {$col < $c} {incr col} { pad $col left "" pad $col right "" } return } ====== somewhere before the creation of the report and use ====== report::report r [m columns] style html ====== to create the report object, see (*) above. ---- Report is '''also''' a [Wub] utility for web and more general [color] manipulation. Latest version may be sourced here [http://wub.googlecode.com/svn/trunk/Utilities/Report.tcl] and perused here [http://code.google.com/p/wub/source/browse/trunk/Utilities/Report.tcl] [CMcC] is the current custodian, but help and improvement is welcome. ---- [hv] I struggled with the report for a while and finally got it. Since the recipe for reporting is somewhat complex, I wrote a procedure called print_matrix to hide all that complexity and to provide an example of how things work. I also wrote a small load_matrix procedure and hope it is useful to somebody. ====== package require csv package require struct::matrix package require report # Loads a CSV file into a matrix proc load_matrix {fileName} { set mx [struct::matrix] set infile [open $fileName r] csv::read2matrix $infile $mx , auto close $infile return $mx } # Prints a matrix as a table with text border proc print_matrix {mx {headerRows 1}} { ::report::defstyle captionedTable {headerRows} { # Top and bottom lines top set "[string repeat "+ = " [columns]]+" bottom set [top get] # Data lines data set "[string repeat "| " [columns]]|" topdata set [data get] # Top caption (AKA headers) topcapsep set "[string repeat "+ - " [columns]]+" tcaption $headerRows topcapsep enable top enable bottom enable } ::report::report r [$mx columns] style captionedTable $headerRows puts [r printmatrix $mx] r destroy } # # main # set mx [load_matrix "users.csv"] print_matrix $mx ====== Sample CSV file (users.csv): ====== ID,alias,Full Name 45,alexd,Alexander Dunn 992,alicek,Alice Kim ====== Sample output: ====== +===+======+==============+ |ID |alias |Full Name | +---+------+--------------+ |45 |alexd |Alexander Dunn| |992|alicek|Alice Kim | +===+======+==============+ ====== <> Package