1. Pre scripts
#!/usr/local/bin/tclsh
proc CheckList {args} {
set vars(-f) "STA_check.csv"
set vars(-out) "ChkPointRpt.csv"
set vars(-d) $ChkListRpt_d
parse_proc_arguments -args $args vars
exec python ./ReadXlsx_pre.py $vars(-f)
foreach myfile [glob -nocomplain test*.csv] {
puts "file name $myfile"
ChkListRpt -f $myfile -out ${myfile}_out.csv -d ${myfile}_debug.csv
}
foreach myfile [glob -nocomplain STA_*_out.csv] {
#exec python ./ReadXlsx_post.py
#
}
foreach myfile [glob -nocomplain STA_*_debug.csv] {
#exec python ./ReadXlsx_post.py
#
}
}
2. post scripts
#!/usr/bin/env python
import sys
import xlrd
import csv
#import time
#tmp_time = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())
data = xlrd.open_workbook(sys.argv[1])
sheet_num = len(data.sheet_names())
lines = ""
for i in range (sheet_num):
table = data.sheets()[i]
print (table)
nrows = table.nrows
for j in range (nrows):
ncols = len(table.row_values(j))
for k in range (ncols):
lines = lines + str(table.row_values(j)[k]) + ","
lines = lines + "\n"
#file_name = "test" + tmp_time + "_" + str(i) + ".csv"
file_name = "STA_checklist" + "_" + str(i) + ".csv"
print (file_name)
with open(file_name,'wb') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar=' ', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow([lines])
lines = ""