Jump to content

gppkuntz

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About gppkuntz

  • Rank
    Newbie
  1. ' you set the keys to be integers starting at zero so your first line is in key 0, zero' I am assuming the first five charcters are account numbers and everything after that is the account value' You can change the msgboxes to writing to files without difficulty' do a split on each line using the space, arr(0) will be the key and arr(1) will be the valueConst ForReading = 1, ForWriting = 2'Set txt filesSet objFSO = CreateObject("Scripting.FileSystemObject")Set objTextFile1 = objFSO.OpenTextFile("C:\wherever\OracleFile.txt", ForReading)Set objTextFile2 = objFSO.OpenTextFile("C:\wherever\HyperionFile.txt", ForReading)'Set f = objFSO.OpenTextFile("C:\wherever\ResultsFile.txt", ForWriting, True)' setup the dictionariesSet Dict1 = CreateObject("Scripting.Dictionary")Set Dict2 = CreateObject("Scripting.Dictionary")Do Until objTextFile1.AtEndOfStream strNextLine = objTextFile1.Readline splitarr = split(strNextLine," ") if Dict1.exists(splitarr(0)) Then ' I assume an account will never occur twice but this is where you should write code just in case ' do nothing Else Dict1.Add splitarr(0), splitarr(1) End IfLoopDo Until objTextFile2.AtEndOfStream strNextLine = objTextFile2.Readline splitarr = split(strNextLine," ") if Dict2.exists(splitarr(0)) Then ' do nothing Else Dict2.Add splitarr(0), splitarr(1) End IfLoop' compare the keys and values of the two dictionariesarrDict1 = Dict1.keysarrDict2 = Dict2.keysstrDict1Keys = Join(arrDict1)strDict2Keys = Join(arrDict2)copyStrDict1Keys = strDict1KeyscopystrDict2Keys = strDict2Keys'msgbox "strDict2Keys = " & strDict2keyss = "accounts that exist in both files"sDifferentValues = "account is the same but values are different"for i = 0 to uBound(arrDict1) if InStr(strDict2Keys, Trim(arrDict1(i))) Then copyStrDict1Keys = replace(copyStrDict1Keys, Trim(arrDict1(i)), "") copystrDict2Keys = replace(copyStrDict2Keys, Trim(arrDict1(i)), "") s = s & vbcrlf & arrDict1(i) if Trim(Dict1.item(arrDict1(i))) <> Trim(Dict2.item(arrDict1(i))) Then sDifferentValues = sDifferentValues &vbcrlf & arrDict1(i) & ": " & Trim(Dict1.item(arrDict1(i))) & ": " & Trim(Dict2.item(arrDict1(i))) End If End IfNextmsgbox smsgbox sDifferentValuesmsgbox "accounts after removing matching: OracleFile " & copyStrDict1Keysmsgbox "accounts after removing matching: HyperionFile " & copyStrDict2Keys'f.closemsgbox "finished" hth
  2. ' you set the keys to be integers starting at zero so your first line is in key 0, zero' I am assuming the first five charcters are account numbers and everything after that is the account value' You can change the msgboxes to writing to files without difficulty' do a split on each line using the space, arr(0) will be the key and arr(1) will be the valueConst ForReading = 1, ForWriting = 2'Set txt filesSet objFSO = CreateObject("Scripting.FileSystemObject")Set objTextFile1 = objFSO.OpenTextFile("C:\wherever\OracleFile.txt", ForReading)Set objTextFile2 = objFSO.OpenTextFile("C:\wherever\HyperionFile.txt", ForReading)'Set f = objFSO.OpenTextFile("C:\wherever\ResultsFile.txt", ForWriting, True)' setup the dictionariesSet Dict1 = CreateObject("Scripting.Dictionary")Set Dict2 = CreateObject("Scripting.Dictionary")Do Until objTextFile1.AtEndOfStream strNextLine = objTextFile1.Readline splitarr = split(strNextLine," ") if Dict1.exists(splitarr(0)) Then ' do nothing Else Dict1.Add splitarr(0), splitarr(1) End IfLoopDo Until objTextFile2.AtEndOfStream strNextLine = objTextFile2.Readline splitarr = split(strNextLine," ") if Dict2.exists(splitarr(0)) Then ' do nothing Else Dict2.Add splitarr(0), splitarr(1) End IfLoop' compare the keys and values of the two dictionariesarrDict1 = Dict1.keysarrDict2 = Dict2.keysstrDict1Keys = Join(arrDict1)strDict2Keys = Join(arrDict2)copyStrDict1Keys = strDict1KeyscopystrDict2Keys = strDict2Keys'msgbox "strDict2Keys = " & strDict2keyss = "accounts that exist in both files"sDifferentValues = "account is the same but values are different"for i = 0 to uBound(arrDict1) if InStr(strDict2Keys, Trim(arrDict1(i))) Then copyStrDict1Keys = replace(copyStrDict1Keys, Trim(arrDict1(i)), "") copystrDict2Keys = replace(copyStrDict2Keys, Trim(arrDict1(i)), "") s = s & vbcrlf & arrDict1(i) if Trim(Dict1.item(arrDict1(i))) <> Trim(Dict2.item(arrDict1(i))) Then sDifferentValues = sDifferentValues &vbcrlf & arrDict1(i) & ": " & Trim(Dict1.item(arrDict1(i))) & ": " & Trim(Dict2.item(arrDict1(i))) End If End IfNextmsgbox smsgbox sDifferentValuesmsgbox "accounts after removing matching: OracleFile " & copyStrDict1Keysmsgbox "accounts after removing matching: HyperionFile " & copyStrDict2Keys'f.closemsgbox "finished"
×
×
  • Create New...