Re: Loop through elements in row of a text file being treated as a Rec
- From: "Ato Bisda" <atobisda@xxxxxxxxx>
- Date: Tue, 28 Jun 2005 16:34:25 -0400
Hello,
The code below will display all the fields for each record in a CSV file named "TEST.TXT"
stored in the folder indicated in the path variable ("c:\yourFolder\").
The code expects a column header row as the first record in the CSV file.
Regards,
Ato
----------------------------------------------------------------------------------
path = "c:\yourFolder\"
Set connCSV = CreateObject("ADODB.Connection")
Set rsText = CreateObject("ADODB.Recordset")
connCSV.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" _
& path & ";Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False"
rsText.Open "Select * From TEST.TXT", connCSV
Do While Not rsText.EOF
Wscript.echo "---------NEW RECORD----------------"
For col = 0 to rsText.fields.count - 1
Wscript.echo rsText.fields(col)
Next
rsText.movenext
Loop
-----------------------------------------------------------------------------------
"ebferro" <ebferro@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EAE5E9BA-E11A-479F-ACD1-C8A386404AA9@xxxxxxxxxxxxxxxx
> I have a text file that I've declared as a CSV text file. Each row in this
> text file has about 20 'columns' of data. Is there a way using the recordset
> object that I can loop through all of the columns in a particular row? The
> first column in every row contains an identifier. I'm using
> objRecordSet.Find to find the row for which I'm looking. Now, I'd like to
> read each column of data in that row and use that as search criteria to
> select records from another database. Is there a method to loop through the
> columns in each row sequentially to do this?
> TIA
> Ernie
.
- References:
- Prev by Date: Script inventory Office versions
- Next by Date: Re: Loop through elements in row of a text file being treated as a
- Previous by thread: Re: Loop through elements in row of a text file being treated as a
- Next by thread: Re: Loop through elements in row of a text file being treated as a Rec
- Index(es):
Relevant Pages
|