本帖最后由 fuinei 于 2012-7-31 15:10 编辑
回复 4# netegg
谢谢netegg元老的指导,根据指导成功把结果读入数组和初步找出指定例(范例中ID列)相同的行号,但折腾了大半天未能实现最终的目标(把ID列相同行的信息写入到result.xls文件中),以下是我的代码,希望各位可以再指导一下,谢谢!#include <File.au3>
#include <Array.au3>
Local $Detailinfo,$LineDetailinfoi,$LineDetailinfoj,$Duplicateinfo
Local $list = @ScriptDir & "\info.txt"
$Result_log = @ScriptDir & "\result.xls"
If FileExists($list) = 1 then
If _FileReadToArray($list,$Detailinfo) = 0 Then
MsgBox(48,"Error","读取数据文件失败,程序将退出!")
Exit
EndIf
Else
MsgBox(48,"Error","无法找到数据文件,程序将退出!")
Exit
EndIf
$file = FileOpen($Result_log,1)
If $file = -1 Then
MsgBox(48,"Error","无法打开日志文件,程序将退出!")
Exit
EndIf
FileWrite($file,"ComputerName" & @TAB & "IP_Address" & @TAB & "ID" & @TAB & "Remark"& @CRLF)
FileClose($file)
For $i = 1 To $Detailinfo[0]
If StringInStr($Detailinfo[$i],"unknown") > 0 Then
ContinueLoop
EndIf
$LineDetailinfoi = StringSplit($Detailinfo[$i],@TAB)
If $LineDetailinfoi[3] = "" then
ContinueLoop
EndIf
Local $Duplicateinfo = _ArrayFindAll($Detailinfo,$LineDetailinfoi[3],0,0,0,1)
_ArrayDisplay($Duplicateinfo)
;.....剩余部分未完成
Next
MsgBox(0,"Info","程序已运行完成,请查看日志!")
ComputerName IP_Address ID Remark
PC01 192.168.1.100 unknown network connection fail
PC02 192.168.1.101
PC03 192.168.1.102 d5199328-a0a2-4d7a-b34e-b46d0911a7f2
PC04 192.168.1.103 379a6577-aa4b-4066-9d17-2d00fa397234
PC05 192.168.1.104 15acb015-4a85-4198-bf3b-f64d1935e5cb
PC06 192.168.1.105 4796fa0a-5586-415c-a320-635b295c9e78
PC07 192.168.1.106 unknown network connection fail
PC08 192.168.1.107 0d030885-daa7-43b8-97d7-2ff60a700571
PC09 192.168.1.108 unknown network connection fail
PC10 192.168.1.109
PC11 192.168.1.110 unknown network connection fail
PC12 192.168.1.111 e6b413f1-2ca9-4bd9-b671-ca265f893406
PC13 192.168.1.112
PC14 192.168.1.113 9f8f7940-189e-439a-b8e8-e13785843570
PC15 192.168.1.114 unknown network connection fail
PC16 192.168.1.115 2b759e67-0691-4062-891e-2d3238d92201
PC17 192.168.1.116 45c3d1de-864f-4f01-81a2-242919e6f9e1
PC18 192.168.1.117 unknown network connection fail
PC19 192.168.1.118 208b5299-b099-43fe-b398-b2d95c16c324
PC20 192.168.1.119
PC21 192.168.1.120 e2c29470-fa68-4192-86fa-96232b2bba86
PC22 192.168.1.121 042166a9-20c5-4d82-900a-6156c61131cf
PC23 192.168.1.122 0be61cd7-7d57-4188-bc66-f4d4e924931c
PC24 192.168.1.123 c86b0785-2022-4a05-bd41-f7362cf2e452
PC25 192.168.1.124 unknown network connection fail
PC26 192.168.1.125 bb7244fb-6875-4e8e-9a09-e24a7e0b9bd1
PC27 192.168.1.126 f025c7c0-7156-4c31-bc7e-db1683b8cee8
PC28 192.168.1.127 379a6577-aa4b-4066-9d17-2d00fa397234
PC29 192.168.1.128 e7b3fa28-ac14-4102-82b7-b5744e4dc9a8
PC30 192.168.1.129 75c81087-003d-4c61-b016-3f62e51e2fde
PC31 192.168.1.130 unknown network connection fail
PC32 192.168.1.131 unknown network connection fail
PC33 192.168.1.132 unknown network connection fail
PC34 192.168.1.133 unknown network connection fail
PC35 192.168.1.134 f1c13063-7550-4ef1-9e88-f31d512345da
PC36 192.168.1.135 379a6577-aa4b-4066-9d17-2d00fa397234
PC37 192.168.1.136 unknown network connection fail
PC38 192.168.1.137 249bee6f-b061-44c7-a14c-884076df3dff
附件为info.txt |