I’m trying to create nice looking report of csv file which contain:
,column_1, column_2,column_3,column_4
line_1,1,2,3,4
line_2,5,6,7,8
line_3,9,0,1,2
line_4,3,4,5,6
The following is my TCL code:
#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}
lappend auto_path .../tcllib/
package require csv
package require struct::matrix
package require report
struct::matrix data
set f [open my.csv "r"]
csv::read2matrix $f data , auto
report::defstyle simpletable {} {
data set [split "[string repeat "| " [columns]]|"]
top set [split "[string repeat "+ - " [columns]]+"]
bottom set [top get]
top enable
bottom enable
}
report::report r 5 style simpletable
r printmatrix data
When I execute it I get:
**report/matrix mismatch in number of columns**
What I did wrong?
Thanks
When I test with exactly what you provided (except that I have a system copy of tcllib; the exact versions I tested with were Tcl 8.5.2, csv 0.7.3, struct::matrix 2.0.2, report 0.3.1, all from ActiveTcl) then it worked fine and produced this output:
All I can think of is that your real data must be not exactly what you think it is. Is there an extra comma on the end of one line of your data?