pre and post scripts for ChkListRpt.tcl

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 = ""


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值