Will A
2014-04-22 17:24:24 UTC
I'm trying to compare an XML file to a Text File and Write the results to the file if they exist. This process is extremely slow and takes 15 minutes. The file I am comparing against in 100MB. The XML file is 1 MB. Please help!
Dim parentNode, objFolder, objFolder2, objPath, objShell, objFile, objXML, objNode, m_MfgPartNumber , m_CageCode
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select EEL Data Extraction Folder", 1, "C:\Scripts\Temp")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder2 = objFSO.GetFolder(objFolder.Self.Path)
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
txt = "C:\Scripts\Results\Validation.txt"
Set oOut = objFSO.CreateTextFile(txt, True)
For each File In objFolder2.Files
objXML.load File.Path
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = oFSO.GetFile(File.Path)
Set m_MfgPartNumber = objXML.documentElement.selectNodes("//ReferenceNumber")
Set m_CageCode = objXML.documentElement.selectNodes("//CageCode")
If Not(m_MfgPartNumber is Nothing) Then
For each i in m_MfgPartNumber
Call Validation()
Next
End if
Next
MsgBox "Process Complete"
'-------------------------------------------------------------------------------------------------------------------------
Sub Validation
Set objFSO = CreateObject("Scripting.FileSystemObject")
sText = "C:\TexFiletoRead.txt"
Set objFile = objFSO.OpenTextFile(sText, 1, True)
Do While Not objFile.AtEndOfStream
sText = objFile.ReadLine
Table Name'
tField1 = Trim(Left(sText,4))
'Cage Code section
tCageCode = trim(mid(sText,5, 5))
'PartNumber location
tPartNumber = trim(mid(sText,10, 10))
'If part number value exists
If tField1 = "HA" then
If i.text = tPartNumber Then
oOut.WriteLine i.text & " " & tPartNumber
End if
End if
Loop
objFile.Close
End Sub
Dim parentNode, objFolder, objFolder2, objPath, objShell, objFile, objXML, objNode, m_MfgPartNumber , m_CageCode
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select EEL Data Extraction Folder", 1, "C:\Scripts\Temp")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder2 = objFSO.GetFolder(objFolder.Self.Path)
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
txt = "C:\Scripts\Results\Validation.txt"
Set oOut = objFSO.CreateTextFile(txt, True)
For each File In objFolder2.Files
objXML.load File.Path
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = oFSO.GetFile(File.Path)
Set m_MfgPartNumber = objXML.documentElement.selectNodes("//ReferenceNumber")
Set m_CageCode = objXML.documentElement.selectNodes("//CageCode")
If Not(m_MfgPartNumber is Nothing) Then
For each i in m_MfgPartNumber
Call Validation()
Next
End if
Next
MsgBox "Process Complete"
'-------------------------------------------------------------------------------------------------------------------------
Sub Validation
Set objFSO = CreateObject("Scripting.FileSystemObject")
sText = "C:\TexFiletoRead.txt"
Set objFile = objFSO.OpenTextFile(sText, 1, True)
Do While Not objFile.AtEndOfStream
sText = objFile.ReadLine
Table Name'
tField1 = Trim(Left(sText,4))
'Cage Code section
tCageCode = trim(mid(sText,5, 5))
'PartNumber location
tPartNumber = trim(mid(sText,10, 10))
'If part number value exists
If tField1 = "HA" then
If i.text = tPartNumber Then
oOut.WriteLine i.text & " " & tPartNumber
End if
End if
Loop
objFile.Close
End Sub