473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ASP Textstream question

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
Jul 19 '05 #1
3 3121
> 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
Jul 19 '05 #2
> cols = split(rows(i), "|")

Sorry, this should say

cols = split(rows(i), delimiter)
Jul 19 '05 #3
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" <an*******@devdex.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
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!

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Bright | last post by:
In an ASP page, I am using the FileSystemObject OpenTextFile method to initiate a TextStream object. In some files I have long lines and it appears that these are being truncated to 2048...
6
by: Christian Blackburn | last post by:
Hi Gang, I have so far been unable to get the TextStream Object to write on Fat32. I'm using Windows 2000 Pro Sp4. Scripts have write access and I even tried giving IUSR user level writes and...
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
1
by: AspProgrammer | last post by:
Hello I'm writing a web application where i upload a file. then i open the file use textstream. At the end of my application i close it by using TextStream.close. But when i try to delete the...
1
by: christine0207 | last post by:
Hi, how to generate a fixed length data text file using Scripting.TextStream / filesystemobject.
1
by: mike.biang | last post by:
I am using the textstream object to read a CSV file and parse through the fields. I use the readline() method to read in each line of the file, and parse the contents into the values of the...
1
by: Madhu G | last post by:
Dim sr As Scripting.TextStream Dim fso As Scripting.FileSystemObject how to use the above code in asp.net
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.