Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Read Specific Value In .csv File

$
0
0
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,

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>