Re: Import CSV
- From: "axtens" <bruce_axtens@xxxxxxxxxxxx>
- Date: 10 Jan 2006 20:01:26 -0800
Nico
Use Split( sLine, "," ) to give you an array of the values.
e.g.
aLine = Split( sLine, "," )
then to redisplay with, say, space between the items
WScript.Echo Join( aLine, " " )
As for saving the values line by line for storage, try this:
Dim OPID, LastName, FirstName, CallDate, LogonTime, LogoffTime,
WorkHours
Dim aVars
aVars = Array( "OPID", "LastName", "FirstName", "CallDate",
"LogonTime", "LogoffTime", "WorkHours" )
then in the body of your do while not eof (or whatever)
aLine = Split( sLine, "," )
For i = 0 To UBound( aLine )
Execute aVars( i ) & " = " & Chr( 34 ) & aLine( i ) & Chr( 34 )
Next
The Execute then evaluates the code, being created here on the fly, to
set the variable whose name is at position i in aVars to be the value
of the item at position i in the record read from the file.
Hope that helps some. I use this technique a lot.
Regards,
Bruce.
<codeaholic.blogspot.com>
.
- Follow-Ups:
- Re: Import CSV
- From: axtens
- Re: Import CSV
- References:
- Import CSV
- From: nvanh
- Re: Import CSV
- From: Slim
- Re: Import CSV
- From: nvanhaaster
- Import CSV
- Prev by Date: Re: need a script to manipulate a file
- Next by Date: Re: Can you pass a Property of a User Defined Object to a Sub ByRef and Update it?
- Previous by thread: Re: Import CSV
- Next by thread: Re: Import CSV
- Index(es):