ASP Textstream question

Discussion in 'ASP General' started by risa, Jul 3, 2003.

  1. risa

    risa Guest

    I tried to read a text file using the Textstream object and each file
    line has 4 elements. How do I put them in 4 separate table cells?
    Thand you very much in advance.
    Risa
    risa, Jul 3, 2003
    #1
    1. Advertising

  2. > I tried to read a text file using the Textstream object and each file
    > line has 4 elements. How do I put them in 4 separate table cells?


    How are the elements separated? Let's say there is a pipe delimiter,


    delimiter = "|" ' or comma, if tab use CHR(9) or vbTab
    set fso = server.createobject("Scripting.FileSystemObject")
    set fs = fso.openTextFile("c:\path\file.txt")
    f = fs.readall()
    fs.close: set fs = nothing: set fso = nothing

    response.write "<table>"
    rows = split(f, vbCrLf)
    for i = 0 to ubound(rows)
    response.write "<tr>"
    cols = split(rows(i), "|")
    for j = 0 to ubound(cols)
    response.write "<td>" & cols(j) & "</td>"
    next
    response.write "</tr>"
    next
    Aaron Bertrand - MVP, Jul 3, 2003
    #2
    1. Advertising

  3. > cols = split(rows(i), "|")

    Sorry, this should say

    cols = split(rows(i), delimiter)
    Aaron Bertrand - MVP, Jul 3, 2003
    #3
  4. You need to show me one of these lines from the file. I have no idea how
    your elements are delimited, I assumed the pipe character, but obviously
    that's not it...

    --
    Aaron Bertrand, SQL Server MVP
    http://www.aspfaq.com/

    Please reply in the newsgroups, but if you absolutely
    must reply via e-mail, please take out the TRASH.


    "risa wu" <> wrote in message
    news:...
    > Hi Aaron: Thank you very much for the help. I am now able to diplay all
    > the line elements on one line but they all showed in one cell. How do I
    > separate them in different cells? Here is my code. Do you have time to
    > help with it?
    > I feel so bad at that stupid coding.
    > <% @language="vbscript" %>
    > <% option explicit %>
    > <html>
    > <title> </title>
    > <body>
    > <div align="center">
    > <table width="600" border="1">
    > <%
    > dim myfso,myts,intlinenum,strlinetext,i,j,f,rows,cols,delimiter
    > const forreading=1
    > delimiter="|"
    > set myfso=server.createobject("scripting.filesystemobject")
    > if myfso.fileexists("d:\gisnet\pplist.txt") then
    > set myts=myfso.opentextfile("d:\gisnet\pplist.txt",forreading)
    > f=myts.readall()
    > rows=split(f,vbcrlf)
    > for i=0 to ubound(rows)
    > response.write "<tr>"
    > cols=split(rows(i),delimiter)
    > for j=0 to ubound(cols)
    > response.write "<td>"& cols(j) &"</td>"
    > next
    > response.write "</tr>"
    > next
    > myts.close
    > else
    > reaponse.write "File was not found"
    > end if
    > %>
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    Aaron Bertrand [MVP], Jul 3, 2003
    #4
    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. Newbie

    Basic question b/w ASP & ASP .NET

    Newbie, Jul 29, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,843
    Steve C. Orr, MCSD
    Jul 30, 2003
  2. Bit Byte
    Replies:
    1
    Views:
    836
    Teemu Keiski
    Jan 28, 2007
  3. Steve Bright

    TextStream Line Truncation

    Steve Bright, Jul 8, 2003, in forum: ASP General
    Replies:
    0
    Views:
    101
    Steve Bright
    Jul 8, 2003
  4. George Hester
    Replies:
    3
    Views:
    200
    Ray at
    Dec 1, 2003
  5. TextStream.ReadLine Mac Newline

    , Jan 8, 2007, in forum: ASP General
    Replies:
    1
    Views:
    162
Loading...

Share This Page