Hi,
I am relatively new to this stuff, so please bear with me. I need to search a .csv file for a specific value (a stored variable), and then pull another value out of a different column on the same row. ... wow tough to explain. Let me try an example.
This is a sample of a .csv file.
"98650042","1","JTH004","DQCR721","IM68", (etc. etc.)
I have a set variable for DQCR721 in my script.
dqNumber = DQCR721
I need to open the .csv file, search for DQCR721, and then set two other variables:
soNumber = 98650042
setNumber = 1
I've searched and searched for examples, but can't find anything that works quite right. I've read two things, one about creating a Database object, which I don't know how to do, and the second is my sample below.
Const ForReading = 1
'Set objRegEx = CreateObject("VBScript.RegExp")
'objRegEx.Pattern = ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\Am\EXCEL2.CSV", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
str = InStr(strSearchString, "98650042")
If str <> 0 Then
msgbox(str)
'Set colMatches = objRegEx.Execute(strSearchString)
' If colMatches.Count > 0 Then
' msgbox(strSearchString)
' End If
Loop
objFile.Close
You can see I've tried various things, but I've not been able to figure it out.
Can someone help point me in the right direction?
Thank-you,
I am relatively new to this stuff, so please bear with me. I need to search a .csv file for a specific value (a stored variable), and then pull another value out of a different column on the same row. ... wow tough to explain. Let me try an example.
This is a sample of a .csv file.
"98650042","1","JTH004","DQCR721","IM68", (etc. etc.)
I have a set variable for DQCR721 in my script.
dqNumber = DQCR721
I need to open the .csv file, search for DQCR721, and then set two other variables:
soNumber = 98650042
setNumber = 1
I've searched and searched for examples, but can't find anything that works quite right. I've read two things, one about creating a Database object, which I don't know how to do, and the second is my sample below.
Const ForReading = 1
'Set objRegEx = CreateObject("VBScript.RegExp")
'objRegEx.Pattern = ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\Am\EXCEL2.CSV", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
str = InStr(strSearchString, "98650042")
If str <> 0 Then
msgbox(str)
'Set colMatches = objRegEx.Execute(strSearchString)
' If colMatches.Count > 0 Then
' msgbox(strSearchString)
' End If
Loop
objFile.Close
You can see I've tried various things, but I've not been able to figure it out.
Can someone help point me in the right direction?
Thank-you,