本来一句SQL就能搞定,用ADO写起来真是很拖沓。
保存为tel.vbs- set fso = CreateObject("Scripting.FileSystemObject")
- s = fso.OpenTextFile("a.txt").ReadAll()
- s = Replace( Replace(s, "_", ","), "-", " ")
- fso.OpenTextFile("a.csv",2,true).Write(s)
- s = fso.OpenTextFile("b.txt").ReadAll()
- s = Replace( Replace(s, "_", ","), "-", " ")
- fso.OpenTextFile("b.csv",2,true).Write(s)
-
- set AdoCnn = CreateObject("ADODB.Connection")
- set AdoRs = CreateObject("ADODB.Recordset")
- AdoCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Extended Properties=""text;HDR=No;FMT=Delimited""; Data Source=."
- AdoRs.Open "select * from (select a.f1 as h, IIF(a.f2,a.f2,b.f2) as i, IIF(a.f3,a.f3,b.f3) as j, IIF(a.f4,a.f4,b.f4) as k, IIF(a.f5,a.f5,b.f5) as l FROM [a.csv] as a LEFT JOIN [b.csv] as b on a.f1=b.f1 UNION SELECT b.* FROM [a.csv] as a RIGHT JOIN [b.csv] as b on a.f1=b.f1 where a.f1 Is NULL) order by k", AdoCnn
- s = AdoRs.GetString(, , ",", vbCrLf, "***")
- AdoRs.Close
- AdoCnn.Close
-
- fso.OpenTextFile("all.csv",2,true).Write(s)
复制代码
|