[实战5]-find out missing data from cdw report

简介:

'***********************************************************
'*         Windows Script Source Code                        *
'*Used for collecting CDW Missing data report          *
'*HM Senior IT: Eric Fu eric.fu@hm.com                   *                   
'*Date: 18 Jan 2016                                                   *
'*Any Site can change infor depend on your request *
'**********************************************************

'on error resume next

sFolder = "C:\temp\cdw\source\"

Dim WDay(7),Wformat

WDay(1)="Sun"

WDay(2)="Mon"

WDay(3)="Tue"

WDay(4)="Wed"

WDay(5)="Thu"

WDay(6)="Fri"

WDay(7)="Sat"

Wformat=WDay(Weekday(Now))
'wscript.echo Wformat

Dim fs, oFolder, oFiles, oSubFolders

set fs = CreateObject("Scripting.FileSystemObject")

set oFolder = fs.GetFolder(sFolder)     '获取文件夹

set oFiles = oFolder.Files              '获取文件集合

for each file in oFiles
    'sExt = fs.GetExtensionName(file)    '获取文件扩展名
    'sExt = LCase(sExt)                  '转换成小写
    'message = "文件名:" & file.Name & ", 扩展名:" & sExt  '获得文件名(含扩展名,不含路径)和扩展名
    excelmessage=file.Name 'get excel file name
    'MsgBox excelmessage
    '====need to kill excel process first====
Next


dim oExcel,oWb,oSheet 

Set oExcel= CreateObject("Excel.Application")
 
Set oWb = oExcel.Workbooks.Open(sFolder & excelmessage) 

'set oSheet = oWb.Sheets("Sheet1")  'MsgBox oSheet.Range("C4").Value 

oExcel.WorkSheets(1).Activate

k=oExcel.ActiveSheet.Range("A65536").End(-4162).Row  '获取A列最后个非空单元格行号

'wscript.echo k

'Msgbox oExcel.Cells(6,4).Value

set flog = fs.OpenTextFile("C:\temp\cdw\MissingStoreLog-"&Wformat&".log", 2,True)

flog.WriteLine("-----Missing Store Log data equal to 0 -----")

for i = 1 to k

if oExcel.Cells(i,4).Value = "0"  then  

'msgbox oExcel.Cells(i,3).Value

set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)

do until fcase.atendofstream
   
   j = 0
   
   strline=fcase.readline

   MyArray=Split(strline,"    ",-1,1)
   
   'msgbox MyArray(0)

   'msgbox MyArray(1)
   
   if oExcel.Cells(i,3).value = MyArray(0) then 
   
   j = j + 1
 
   exit do 
   
   end if 
   
loop

if j = 1 then 

flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))

else 

flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")

end if 

 set MyArray = nothing
   
 j = 0

fcase.close

'flog.WriteLine (oExcel.Cells(i,3).Value)

end if

Next 

'=========missing store log data equal to null==========

flog.WriteLine("-----Missing Store Log data equal to null -----")

for i = 1 to k

if oExcel.Cells(i,4).Value = ""  then  

'msgbox oExcel.Cells(i,3).Value

'flog.WriteLine (oExcel.Cells(i,3).Value)

set fcase=fs.opentextfile("C:\temp\cdw\case.txt",1,false)

do until fcase.atendofstream
   
   j = 0
   
   strline=fcase.readline

   MyArray=Split(strline,"    ",-1,1)
   
   'msgbox MyArray(0)

   'msgbox MyArray(1)
   
   if oExcel.Cells(i,3).value = MyArray(0) then 
   
   j = j + 1
 
   exit do 
   
   end if 
   
loop

if j = 1 then 

flog.WriteLine (oExcel.Cells(i,3).value & chr(9) & MyArray(1))

else 

flog.WriteLine (oExcel.Cells(i,3).Value & chr(9) &"Create New Case")

end if 

 set MyArray = nothing
   
 j = 0

fcase.close

end if

Next 

wscript.sleep 1000

oExcel.WorkBooks.Close 

oExcel.Quit  

flog.Close()

set flog = nothing

set fs = nothing


本文转自 bilinyee博客,原文链接:    http://blog.51cto.com/ericfu/1736338    如需转载请自行联系原作者


相关文章
|
Java
Leetcode 295. Find Median from Data Stream
在一个有序数组中找中位数,但需要支持再数组中添加新的元素。本来是有序里的,可以很轻易就查到中位数,但如果添加新数字后,不一定有序。如果先对数组排序,那代价就比较大了,每次排序时间复杂度O(n*log(n)),看discuss发现了一种很巧妙的解法,可以把添加数据的时间复杂度降低到O(log(n)) ,查询中位数O(1)。
55 0
|
4月前
|
搜索推荐 Docker 容器
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
执行 `DimPlot` 函数时遇到错误 `;Error in Ops. data. frame(g guides_loc, panel_loc) : '==' only defined for equally-sized data frames`。解决方案和办法
1236 0
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
|
Python
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Python报错ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
1724 1
|
7月前
|
索引
Elasticsearch exception [type=illegal_argument_exception, reason=index [.1] is the write index for data stream [slowlog] and cannot be deleted]
在 Elasticsearch 中,你尝试删除的索引是一个数据流(data stream)的一部分,而且是数据流的写入索引(write index),因此无法直接删除它。为了解决这个问题,你可以按照以下步骤进行操作:
513 0
|
7月前
|
存储
tracker_query_storage fail, error no: 28, error info: No space left on device
tracker_query_storage fail, error no: 28, error info: No space left on device
175 0
|
7月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
|
XML 数据格式
XML问题: The processing instruction target matching "[xX][mM][lL]" is not allowed
XML问题: The processing instruction target matching "[xX][mM][lL]" is not allowed
220 0
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
184 0

热门文章

最新文章