From: Gadgetman on
I am trying to read a list of fields from one file, then compare them to a
list in a second file. If the field I am comparing is the same, it reads a
second field from the second file and then output the
contents of the first file and then second field from the second file.

For example, first file has three rows:
A, B, C, D
E, F, G, H
Q, R, S, D
Second file has two rows:
D, 5
H, 1

When I run my script, I should get the following output:
A, B, C, D, 5
E, F, G, H, 1
Q, R, S, D, 5

But what I am getting is:

A, B, C, D
E, F, G, H, 1
Q, R, S, D

Here is the portion of the script that is giving me the problems:

Do Until objInput.AtEndOfStream
strLine = objInput.ReadLine
' Skip blank lines.
If (Trim(strLine) <> "") Then
' Parse the fields in the file.
arrValues = CSVParse(strLine) 'Copyright (c) 2007 Richard L. Mueller
Hilltop Lab web site - http://www.rlmueller.net
' Set variables for each field read from file.
strCount = strCount +1
strFirst = arrValues(0)
strSecond = arrValues(1)
strThird = arrValues(2)
strFourth = arrValues(3)
Set objCFile = objFSO.OpenTextFile("File2.txt", ForReading)
' Next part should read from text csv file that contains two fields - first
field is a list of values that will equal strFourth from First file
Do Until objCFile.AtEndOfStream
strCline = objCFile.Readline
arrFields = Split(strCLine, ",")
strChars = arrFields(0)
If strFourth = strChars Then strNCount = arrFields(1)
'Else
'End If
Loop
objCFile.Close

objOutput.WriteLine strCount & "," & strFirst & "," & strSecond & "," &
strThird & "," strFourth & "," strNCount


Any assistance in this matter is greatly appreciated.
From: Gadgetman on
The script actually works - another part of the script was performing a test
routine to see how many of each and this was causing the problem.

"Gadgetman" wrote:

> I am trying to read a list of fields from one file, then compare them to a
> list in a second file. If the field I am comparing is the same, it reads a
> second field from the second file and then output the
> contents of the first file and then second field from the second file.
>
> For example, first file has three rows:
> A, B, C, D
> E, F, G, H
> Q, R, S, D
> Second file has two rows:
> D, 5
> H, 1
>
> When I run my script, I should get the following output:
> A, B, C, D, 5
> E, F, G, H, 1
> Q, R, S, D, 5
>
> But what I am getting is:
>
> A, B, C, D
> E, F, G, H, 1
> Q, R, S, D
>
> Here is the portion of the script that is giving me the problems:
>
> Do Until objInput.AtEndOfStream
> strLine = objInput.ReadLine
> ' Skip blank lines.
> If (Trim(strLine) <> "") Then
> ' Parse the fields in the file.
> arrValues = CSVParse(strLine) 'Copyright (c) 2007 Richard L. Mueller
> Hilltop Lab web site - http://www.rlmueller.net
> ' Set variables for each field read from file.
> strCount = strCount +1
> strFirst = arrValues(0)
> strSecond = arrValues(1)
> strThird = arrValues(2)
> strFourth = arrValues(3)
> Set objCFile = objFSO.OpenTextFile("File2.txt", ForReading)
> ' Next part should read from text csv file that contains two fields - first
> field is a list of values that will equal strFourth from First file
> Do Until objCFile.AtEndOfStream
> strCline = objCFile.Readline
> arrFields = Split(strCLine, ",")
> strChars = arrFields(0)
> If strFourth = strChars Then strNCount = arrFields(1)
> 'Else
> 'End If
> Loop
> objCFile.Close
>
> objOutput.WriteLine strCount & "," & strFirst & "," & strSecond & "," &
> strThird & "," strFourth & "," strNCount
>
>
> Any assistance in this matter is greatly appreciated.