微软 脚本专家
如何从文本文件中删除所有重复行?
http://www.microsoft.com/china/t ... rces/hey050819.mspx
http://msdn.microsoft.com/en-us/library/ms974559- Const adOpenStatic = 3
- Const adLockOptimistic = 3
- Const adCmdText = &H0001
-
- Set objConnection = CreateObject("ADODB.Connection")
- Set objRecordSet = CreateObject("ADODB.Recordset")
-
- strPathToTextFile = "C:\Scripts\"
- strFile = "Test.txt"
-
- objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=" & strPathtoTextFile & ";" & _
- "Extended Properties=""text;HDR=NO;FMT=Delimited"""
-
- objRecordSet.Open "Select DISTINCT * FROM " & strFile, _
- objConnection, adOpenStatic, adLockOptimistic, adCmdText
-
- Do Until objRecordSet.EOF
- Wscript.Echo objRecordSet.Fields.Item(0).Value
- objRecordSet.MoveNext
- Loop
复制代码 速度还不错,但文本不能太复杂,因为有FMT=Delimited
或者通过Schema.ini文件指定按固定长度(但长度多少才算合适?) |