ASP Textstream question

R

risa

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
 
A

Aaron Bertrand - MVP

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
 
A

Aaron Bertrand - MVP

cols = split(rows(i), "|")

Sorry, this should say

cols = split(rows(i), delimiter)
 
A

Aaron Bertrand [MVP]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top