0
votes

It’s really appreciated if someone would have help me on this using vbs script. I have text file with 4 gb data (below sample data--at end it is) and I need only these three columns data out of my attached textfile

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

Without duplicate data since I have many of them are similar ldap ids are there. so i need to take only with unique of ids with three columns,Please can you help me how to achive using vbs script. Finally I need my output will be following way with out dulicates:

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

my sample data is here:

"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

1 Answers

0
votes

Describe your input file using a schema.ini file:

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

(minimalistic/need to know version to get it 'to work'; you surely can do better)

Open a ADODB Connection to your input file, select your 3 columns 'distinct'ly, and write the records quoted to StdOut (or a file):

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

That should give you:

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"