Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP Textstream question

Reply
Thread Tools

ASP Textstream question

 
 
risa
Guest
Posts: n/a
 
      07-03-2003
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
 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      07-03-2003
> 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


 
Reply With Quote
 
 
 
 
Aaron Bertrand - MVP
Guest
Posts: n/a
 
      07-03-2003
> cols = split(rows(i), "|")

Sorry, this should say

cols = split(rows(i), delimiter)


 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      07-03-2003
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.filesystemobj ect")
> if myfso.fileexists("d:\gisnet\pplist.txt") then
> set myts=myfso.opentextfile("d:\gisnet\pplist.txt",for reading)
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextStream.ReadLine Mac Newline mike.biang@gmail.com ASP General 1 01-09-2007 02:20 PM
[ASP.NET1.1]Should I kill the ASP.NET worker process after recompilingmy ASP.NET webservice? Andrea Raimondi ASP .Net 1 02-06-2006 08:10 AM
ASP.Net cookie -> ASP -> ASP.Net Ben ASP .Net 3 05-28-2004 03:35 PM
Write permissions using Scripting.TextStream object George Hester ASP General 3 12-01-2003 02:56 AM
TextStream Line Truncation Steve Bright ASP General 0 07-08-2003 01:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57