Reply
Reading from a file
Old 11-28-2006, 08:17 PM Reading from a file
VTWebProperties's Avatar
Skilled Talker

Latest Blog Post:
WEB 2.0 Apps For iPhone
Posts: 63
Name: Ed
Location: Vermont
Can someone give quick code sample on reading a tab-delimited file in ASP?

The format would be

data[tab]data[tab]data[tab]data[newline]
data[tab]....
VTWebProperties is offline
Reply With Quote
View Public Profile Visit VTWebProperties's homepage!
 
When You Register, These Ads Go Away!
     
Old 11-30-2006, 03:39 PM Re: Reading from a file
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
What do you need to do with the data that's tab delimited?

It's 2 parts. The examples shown below are completely separate and you will need to integrate them to get the desired result

1st is reading the file (http://www.w3schools.com/asp/asp_ref_textstream.asp)

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject ")

Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)
Response.Write(f.ReadAll)
f.Close

Set f=Nothing
Set fs=Nothing
%>

2nd part is splitting the delimited text by putting it into an array:
<%
Dim strTabs
strTabs = "this is a test of tabs" ' text you want to split

arrayTabs = Split(strTabs, " ") 'split when there are 5 spaces could be replaced with comma to separate by comma

For i = 0 to 6
Response.Write(arrTabs & "<br>") ' output of split text
Next
%>

will appear as:
this
is
a
test
of
tabs
__________________
Daniel
"I think therefore I am, I think." <!-- George Carlin
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Reply     « Reply to Reading from a file
 

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11493 seconds with 13 queries