使用vbs选择的列没有重复

时间:2015-11-22 04:57:32

标签: vbscript

非常感谢有人会使用vbs脚本帮助我。 我有4 gb数据的文本文件(下面是示例数据 - 最后是它)我只需要这三列数据来自我附加的文本文件

"20150901162037","20150901162037","LDAP_Prod/xyrep, tett"

没有重复的数据,因为我有很多类似的ldap ID。 所以我只需要使用三列唯一的ID,请你能帮助我如何使用vbs脚本。 最后,我需要我的输出将按照以下方式输出:

"20150901162037","20150901162037","LDAP_Prod/xyrep, tett"
"20150901162037","20150901162037","LDAP_Prod/ttin_tess"
.
…

我的样本数据在这里:

"100aEB","20150901162037","20150901162037","LDAP_Prod/xyrep, tett","N","11937.91666666667","0","Test_Plan","360610","BAU","Version1","Budget","LDDRR","31029","21240","36542_31029","2016","Jan","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ xyrep, tett ","N","11937.91666666667","0","SS_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Feb","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ttin_tess","N","11937.91666666667","0","LLL_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Aug","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ xyrep, tett ","N","11937.91666666667","0","SS_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Feb","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ttin_tess","N","11937.91666666667","0","LLL_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Aug","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ttin_tess","N","11937.91666666667","0","LLL_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Aug","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ttenetess","N","11937.91666666667","0","LLL_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Aug","6050210000",""

"100aEB","20150901162037","20150901162037","LDAP_Prod/ttin_tess","N","11937.91666666667","0","LLL_Plan","360610","BAU","Version1","Budget","LDGR","31029","21240","36542_31029","2016","Aug","6050210000",""

1 个答案:

答案 0 :(得分:0)

使用schema.ini文件描述您的输入文件:

[33851749.txt]
Format=CSVDelimited
ColNameHeader=False
DecimalSymbol=.
Col1=AA Text
Col2=BB Text
Col3=CC Text
Col4=DD Text

(简约/需要知道版本才能让它'上班';你肯定可以做得更好)

打开输入文件的ADODB Connection,选择3列'distinct',然后将引用的记录写入StdOut(或文件):

Option Explicit

Const adClipString = 2

Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim oDB : Set oDB = CreateObject("ADODB.Connection")
Dim sCS : sCS     = Join(Array( _
    "Provider=Microsoft.Jet.OLEDB.4.0" _
  , "Data Source=" & oFS.GetAbsolutePathName("..\data") _
  , "Extended Properties=""text""" _
), ";")
oDB.Open sCS
Dim sSQL : sSQL    = "Select Distinct BB, CC, DD from [33851749.txt]"
Dim oRS  : Set oRS = oDb.Execute(sSQL)
Do Until oRS.EOF
   WScript.Echo """" & oRS.GetString(adClipString, 1, """,""", """", """""")
Loop

oDB.Close

那应该给你:

cscript 33851749.vbs
"20150901162037","20150901162037","LDAP_Prod/ xyrep, tett"
"20150901162037","20150901162037","LDAP_Prod/ttenetess"
"20150901162037","20150901162037","LDAP_Prod/ttin_tess"
"20150901162037","20150901162037","LDAP_Prod/xyrep, tett"