- On Error Resume Next
- Dim srcFile, dic, fso, objFile, s, arr
- srcFile = "1.txt" '源文件
-
- Set dic = CreateObject("Scripting.Dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set objFile = fso.OpenTextFile(srcFile, 1)
-
- while Not objFile.AtEndOfStream
- s = objFile.ReadLine
- arr = Split(s, "|", 2)
- If Not dic.Exists(arr(0)) Then
- dic.Item(arr(0)) = s
- Else
- dic.Item(arr(0)) = dic.Item(arr(0)) + "&" + arr(1)
- End If
- wend
-
- WSH.Echo Join(dic.Items, vbCrLf)
复制代码
|