Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need to add to an existing VBS script - to read the contents of a CSV file and locate specific data, then the check the date to see if it matches the current date. Based on what it finds, it needs to send an email. I have the Sub written to send the email, but I don't know how to read the CSV file to locate the text.
This is my first foray into VBS scripting - I'm looking for sample code, suggested refrences/groups, etc.
TIA,
Joe

Joe,
Your best bet here is to use the FileSystemObject to open a file, parse it, then perform your functions once you find the relevant data.
You will want to use the OpenTextFile method to open the CSV file. This returns a TextStream object. On this TextStream object, you can call the .ReadAll or .ReadLine method. These will read the data into the TextStream object. You can then search this data using vaious methods such as InStr(), etc.
An alternative would be to use the XML DOM to load the CSV into an XML object, then use XPath to search certain sections which contain the data you are looking for. You can map columns to nodes in the XML, etc.
FSO reference: http://www.tutorial-web.com/asp/fso/
XML Reference: http://www.devguru.com/Technologies/xmldom/QuickRef/xmldom_intro.html
You may also want to search for "CSV to XML code" for examples on the web. I have done this many times and would be happy to provide sample code on both methods mentioned above if you email me.
Hope this points you in the right direction.
Curtis Hughes
StreamLogic Inc.
http://www.streamlogicinc.com

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |