Re: Loop through elements in row of a text file being treated as a Rec



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


.



Relevant Pages

  • Re: Parsing large CSV data file.
    ... I have a 180MB csv file. ... My objective is to find how many of those 2 char. ... the 'commas' and 'numbers' from the row before doing this... ... whole loop looks like, ...
    (comp.soft-sys.matlab)
  • Re: HOW TO: CONVERT CSV DELIMITED FILES TO XLS
    ... See Chip Pearson's site for code that will read in a CSV file - you can ... You can loop through a directory with ... It is important to> recognize the comma delimiter and throw the comma-separated individual values> in different cells. ...
    (microsoft.public.excel.programming)
  • Re: Can anyone explain PHP slowing down please ?
    ... I'm processing a large csv file and when I loop through it I can process around 275 records per second. ... I was wondering if anyone with strong PHP knowledge has heard of this or could help explain it please ... open database for read-only here ...
    (comp.lang.php)
  • RE: Append text
    ... Make a copy of the .csv file to test this with so that your original doesn't ... Dim myFileNum As Integer ... Dim RC as Integer ' row counter for loop ...
    (microsoft.public.excel.misc)

Quantcast