Option Explicit
Dim adoCSVConnection, adoCSVRecordSet, strPathToTextfile
Dim strCSVFile, k
' Specify path to CSV file.
strPathToTextFile = "c:\Scripts\"
' Specify CSV file name.
strCSVFile = "DomainUsers.csv"
' Open connection to the CSV file.
Set adoCSVConnection = CreateObject("ADODB.Connection")
Set adoCSVRecordSet = CreateObject("ADODB.Recordset")
' Open CSV file with header line.
adoCSVConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=NO;FMT=Delimited"""
adoCSVRecordset.Open "SELECT * FROM " & strCSVFile, adoCSVConnection
' Read the CSV file.
Do Until adoCSVRecordset.EOF
' Display all fields.
For k = 0 To adoCSVRecordset.Fields.Count - 1
Wscript.Echo adoCSVRecordset.Fields(k).Value
Next
adoCSVRecordset.MoveNext
Loop
' Clean up.
adoCSVRecordset.Close
adoCSVConnection.Close
Tuesday, 5 December 2017
Vbscript: Reading CSV file using ADODB
Subscribe to:
Post Comments (Atom)
-
Description Waits until the specified object property achieves the specified value or exceeds the specified timeout ...
-
Option Explicit Dim adoCSVConnection, adoCSVRecordSet, strPathToTextfile Dim strCSVFile, k ' Specify path to CSV file. strPathToTextF...
-
QTP AOM Script : Launch QTP, Create new test and Save it =============================================== dim qtpapp set qtpapp=create...
No comments:
Post a Comment