;生成测试log文件
Dim $i
Dim $logfilename
Dim $fhandle
Dim $buf
Dim $sc_path
$sc_path = @ScriptDir
If StringRight($sc_path, 1) <> "\" Then $sc_path &= "\"
For $i = 1 To 100
$logfilename = "log" & $i & ".log"
$fhandle = FileOpen($sc_path & $logfilename, 10)
$buf = "A:" & Random(1, 10, 1) & @CRLF
$buf &= "B:" & Random(1, 10, 1) & @CRLF
FileWrite($fhandle, $buf)
FileClose($fhandle)
Next
MsgBox(0, "测试用log文件已生成", "")
;提取log文件输出csv
Dim $i
Dim $logfilename
Dim $fhandle
Dim $buf
Dim $sc_path
Dim $var_a
Dim $var_b
Dim $csv
$sc_path = @ScriptDir
If StringRight($sc_path, 1) <> "\" Then $sc_path &= "\"
$csv = ",A,B" & @CRLF
For $i = 1 To 100
$logfilename = "log" & $i & ".log"
$fhandle = FileOpen($sc_path & $logfilename, 0)
$buf = FileRead($fhandle)
FileClose($fhandle)
$n = StringRegExp($logfilename, ".+?(?=\.)", 3)
$csv &= $n[0] & ","
$n = StringRegExp($buf, "(?<=:).*?(?=\s)", 3)
$csv &= $n[0] & "," & $n[1] & @CRLF
Next
$fhandle = FileOpen($sc_path & "log.csv", 10)
FileWrite($fhandle, $csv)
FileClose($fhandle)
MsgBox(0, "提取文件完成", "")
|