Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Import CSV

5 views
Skip to first unread message

nv...@shaw.ca

unread,
Jan 10, 2006, 12:26:40 AM1/10/06
to
Hello,

I have a few question, possible a redirect to a tutorial that explains
this better, I am looking to have a text file (CSV) being read i have
the code to upload and auto open the file.

I need ASP to read the CSV file to read lines 2 on-wards and display it
back to the user for verification. Each line has aprx 8 "," that
control user properties.

I am looking for each line to be displayed back to the user without the
"," so they can verify and write to an access db.

All i am looking for is a simple way to read the text display to the
user for acceptance before writing it back to the db.

Slim

unread,
Jan 10, 2006, 9:37:15 AM1/10/06
to
using the right connection string you should be able to open it as a
database, assuming you know how to manipulate a database.

or you could use
set fso = CreateObject("Scripting.FileSystemObject")

assuming you know how to manipulate test strings, please indicate if you
need more help

<nv...@shaw.ca> wrote in message
news:1136870800....@f14g2000cwb.googlegroups.com...

nvanh...@caitele.com

unread,
Jan 10, 2006, 3:17:52 PM1/10/06
to

Slim wrote:
> using the right connection string you should be able to open it as a
> database, assuming you know how to manipulate a database.
>
> or you could use
> set fso = CreateObject("Scripting.FileSystemObject")
>
> assuming you know how to manipulate test strings, please indicate if you
> need more help

I am pulling my hair out trying to get this to work, i have read alot
of examples, tutorials.

Here is what the lines look like.
OPID,Last Name,First Name,Call Date,Logon Time,Logoff Time,Work Hours
0084,DALTON, ANGELA,01-08-06,15:07:29,16:04:04,00:56:35,

I need to open the file named AB0108.txt
Open a db called payroll.mdb

I then want to display all the text from the file without comma's on a
separate line
while displaying i need it to save the text to a variable to write to
the corresponding column in the database.
ie.
EMPID = OPID
LNAME = last name
FName = first name

and so on.. Does anyone have any ideas? A tutorial a script an example
would be AMAZING

CHEERS,
Nico

axtens

unread,
Jan 10, 2006, 11:01:26 PM1/10/06
to
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>

axtens

unread,
Jan 11, 2006, 1:40:04 AM1/11/06
to
Nico

I've gone so far as to make an entry in the blog about this issue. The
beginnings of a solution to your query can be found at
<http://codeaholic.blogspot.com/2006/01/vbscript-csv-to-variables-using.html>

Regards,
Bruce.

nvanh...@caitele.com

unread,
Jan 11, 2006, 12:17:49 PM1/11/06
to

Bruce,

I appreciate your help with a little extra tweaking it worked great,
Thanks again!

Cheers,

Nico

0 new messages