本帖最后由 顽固不化 于 2009-7-28 21:24 编辑 $Fhd = FileOpen("gg.txt", 0)
Dim $line[1]
$B = 1
While 1
$TxtLine = FileReadLine($Fhd, $B)
If @error Then ExitLoop
If $TxtLine="" Then ContinueLoop
$B = $B + 1
ReDim $line[$B]
$line[$B - 1] = $TxtLine
WEnd
FileClose($Fhd)
If $B=1 Then
MsgBox(16,"错误","原始TXT文件是空的!")
Exit
EndIf
$line[0]=$B-1
Dim $newline[2]
$newline[1] = $line[1]
$N = 2
$issam = False
For $o = 2 To $line[0]
$word = StringSplit($line[$o], ",")
For $j = 1 To $n - 1
$temp = StringSplit($newline[$j], ",")
If $word[2] = $temp[2] Then
$newline[$j] = $line[$o]
$issam = True
ExitLoop
EndIf
Next
If $issam = False Then
$N = $N + 1
ReDim $newline[$N]
$newline[$N - 1] = $line[$o]
Else
$issam = False
EndIf
Next
$newline[0] = $N - 1
$Fhd = FileOpen("newtxt.txt", 10)
For $i = 1 To $newline[0]
FileWriteLine($Fhd, $newline[$i])
Next
FileClose($Fhd)
|