Скрипт чтения CSV файла с выводом в читаемом виде
Option Explicit
On Error Resume Next
Dim arrTxtArray()
Dim appLog
Dim SearchString
Dim objTextFile
Dim strNextLine
Dim intSize
Dim objFSO
Dim i
Dim ErrorString
Dim newArray
intSize = 0
appLog = "C:\twst\applog.csv"
SearchString = ","
ErrorString = "1004"
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(appLog, ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
If InStr (strNextLine, SearchString) Then
If InStr ( strNextLine, ErrorString) Then
ReDim Preserve arrTxtArray(intSize)
arrTxtArray(intSize) = strNextLine
intSize = intSize +1
End If
End If
Loop
objTextFile.close
For i = LBound(arrTxtArray) To UBound(arrTxtArray)
If InStr (arrTxtArray(i), ",") Then
newArray = Split (arrTxtArray(i), ",")
WScript.Echo "Date: " & newArray(0)
WScript.Echo "Time: " & newArray(1)
WScript.Echo "Source: " & newArray(2)& " "& newArray(3)
WScript.Echo "Server: " & newArray(7)
WScript.Echo "Message1: " & newArray(8)
WScript.Echo "Message2: " & newArray(9)
WScript.Echo "Message3: " & newArray(10)
WScript.Echo " "
End If
Next
WScript.Echo("all done")
Интересное на сайте:
Голосов пока нет

Оставить комментарий