generate CSV or comma delimited

Discussion in 'ASP General' started by shank, Jul 8, 2003.

  1. shank

    shank Guest

    What's the easiest way to generate CSV or a comma delimited file from an ASP
    recordset? I've seen a few searching the internet and they appear to be
    overkill or out of date.

    thanks
    shank, Jul 8, 2003
    #1
    1. Advertising

  2. Did you see any that use GetString() ?




    "shank" <> wrote in message
    news:...
    > What's the easiest way to generate CSV or a comma delimited file from an

    ASP
    > recordset? I've seen a few searching the internet and they appear to be
    > overkill or out of date.
    >
    > thanks
    >
    >
    Aaron Bertrand - MVP, Jul 8, 2003
    #2
    1. Advertising

  3. shank

    Ray at Guest

    Something like:

    Do while not rs.EOF
    For each f in rs.fields
    sOutput = sOutput & f.value & ","
    Next
    sOutput = sOutput & vbCrLf
    Loop

    Then write sOutput to a file using FSO. (If you're not sure about that,
    post back.)

    Not tested

    Ray at work




    "shank" <> wrote in message
    news:...
    > What's the easiest way to generate CSV or a comma delimited file from an

    ASP
    > recordset? I've seen a few searching the internet and they appear to be
    > overkill or out of date.
    >
    > thanks
    >
    >
    Ray at, Jul 8, 2003
    #3
  4. shank

    shank Guest

    Do you happen to have some code example?
    Beginning to end...?
    The following code appears to be working, but no results.
    thanks

    "Ray at <%=sLocation%>" <> wrote in message
    news:%...
    > Something like:
    >
    > Do while not rs.EOF
    > For each f in rs.fields
    > sOutput = sOutput & f.value & ","
    > Next
    > sOutput = sOutput & vbCrLf
    > Loop
    >
    > Then write sOutput to a file using FSO. (If you're not sure about that,
    > post back.)
    >
    > Not tested
    >
    > Ray at work
    >
    >
    >
    >
    > "shank" <> wrote in message
    > news:...
    > > What's the easiest way to generate CSV or a comma delimited file from an

    > ASP
    > > recordset? I've seen a few searching the internet and they appear to be
    > > overkill or out of date.
    > >
    > > thanks
    > >
    > >

    >
    >
    shank, Jul 8, 2003
    #4
  5. Hello

    Try this:

    Set fs=Server.CreateObject("Scripting.FileSystemObject")
    Set ctf = fs.CreateTextFile(Server.MapPath("test.csv"), 2)

    If Not rset1.EOF Then
    ctf.WriteLine("ISP,Address") '*** If you want titles to your columns
    for your csv file

    While Not rset1.EOF
    ctf.WriteLine(""""&(rset1.Fields("ISP").Value)&""","""&(rset1.Fields("Address").Value)&"""")
    rset1.movenext
    Wend
    End if

    ctf.Close
    Set fs=nothing

    '**************************************
    simple loops through your recordset writing out the fields on a line
    with commas and creates new line per record, it will also put double
    quote around all values, you will need to create a recordset, replace
    my recordset tags with yours e.g. (rset1.Fields("ISP").Value), you
    will also need to change the titles e.g. ("ISP,Address") to the titles
    you want for each column.

    CSV File Format should look something like: (using my recordset
    fields)

    ISP,Address
    "ISP Name1","ISP Address1"
    "ISP Name2","ISP Address2"

    etc.

    Hope this helps, I have quickly simplified code hope I haven't made
    any mistakes.

    "shank" <> wrote in message news:<>...
    > Do you happen to have some code example?
    > Beginning to end...?
    > The following code appears to be working, but no results.
    > thanks
    >
    > "Ray at <%=sLocation%>" <> wrote in message
    > news:%...
    > > Something like:
    > >
    > > Do while not rs.EOF
    > > For each f in rs.fields
    > > sOutput = sOutput & f.value & ","
    > > Next
    > > sOutput = sOutput & vbCrLf
    > > Loop
    > >
    > > Then write sOutput to a file using FSO. (If you're not sure about that,
    > > post back.)
    > >
    > > Not tested
    > >
    > > Ray at work
    > >
    > >
    > >
    > >
    > > "shank" <> wrote in message
    > > news:...
    > > > What's the easiest way to generate CSV or a comma delimited file from an

    > ASP
    > > > recordset? I've seen a few searching the internet and they appear to be
    > > > overkill or out of date.
    > > >
    > > > thanks
    > > >
    > > >

    > >
    > >
    Paul Hamlington, Jul 9, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yama

    Comma Delimited

    Yama, Dec 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    383
    Ken Cox [Microsoft MVP]
    Dec 16, 2003
  2. Luis Esteban Valencia

    Read Comma Delimited File

    Luis Esteban Valencia, Jul 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,799
    Paul Clement
    Jul 27, 2005
  3. Edward A Thompson

    JavaMail MimeMessage - comma delimited?

    Edward A Thompson, Oct 8, 2003, in forum: Java
    Replies:
    9
    Views:
    5,598
    GaryM
    Oct 10, 2003
  4. ouioui
    Replies:
    1
    Views:
    1,610
    Mukul Gandhi
    Sep 23, 2004
  5. RyanL
    Replies:
    6
    Views:
    667
    Paul McGuire
    Aug 28, 2007
Loading...

Share This Page