2
我試圖創建包含CSV文件的好看報告:TCL:由tcllib報表打印CSV文件報告
,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
以下是我的TCL代碼:
#!/bin/sh
# \
exec tclsh "$0" ${1+"[email protected]"}
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
當我執行它我得到:
**report/matrix mismatch in number of columns**
我做錯了什麼?
感謝
你好,唐納,爲你的答案。幸運的是,數據文件是確定的,但我發現我需要修改代碼的最後一行:「printmatrix data」 - >「puts [printmatrix data]」。 – 2012-03-04 20:12:15
是的,沒想到提及。大多數Tcl命令不直接打印輸出,因爲這會降低其靈活性。 :-) – 2012-03-04 20:29:19