|
Technical Interview Questions
Visual Basic Interview Question
.NET Web Interview Questions
.NET
Interview Questions
C#
Interview Questions
.........More
Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
Asp/VB Script Source Codes
Display CSV Files Using ASP
<P>CSV files are common formats to get information . I have seen commission
sites , stock quotes and various links in these types of files . CSV are comma
seperated value files , the typical format of one of these could be like
this.</P>
<P>1000,age,234,billy</P>
<P>This is not much to look at but with a little scripting we can make it more
readable . In this example we have a stock quotes csv file downloaded from Yahoo
which we wish to display.</P>
<P><%<BR>'declare our variables<BR>Dim objFSO , strURL , objFile<BR>'create
an instance of the file system object<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")<BR>'this
is the csv file downloaded from yahoo<BR>strURL = Server.MapPath("quotes.csv")<BR>'open
the file<BR>Set objFile = objFSO.OpenTextFile(strURL)<BR>'while we are not at
the end of the file<BR>Do While Not objFile.AtEndOfStream<BR>'store the contents
of the file in strText<BR>strText = objFile.readLine<BR>'split the strText <BR>arrText
= split(strText, ",", 9)<BR>Loop<BR>'close and destroy objects<BR>objFile.Close<BR>Set
objFile = Nothing<%<BR>'declare our variables<BR>Dim objFSO , strURL ,
objFile<BR>'create an instance of the file system object<BR>Set objFSO =
Server.CreateObject("Scripting.FileSystemObject")<BR>'this is the csv file
downloaded from yahoo<BR>strURL = Server.MapPath("quotes.csv")<BR>'open the
file<BR>Set objFile = objFSO.OpenTextFile(strURL)<BR>'while we are not at the
end of the file<BR>Do While Not objFile.AtEndOfStream<BR>'store the contents of
the file in strText<BR>strText = objFile.readLine<BR>'split the strText <BR>arrText
= split(strText, ",", 9)<BR>Loop<BR>'close and destroy objects<BR>objFile.Close<BR>Set
objFile = Nothing<BR>Set objFSO = Nothing<BR>%><BR><table><BR><tr><td>description</td><td>latest
figure</td><tr><BR><tr><td>symbol</td><td><%=
arrText(0) %></td></tr><BR><tr><td>last price</td><td><%=
arrText(1) %></td></tr><BR><tr><td>date</td><td><%=
arrText(2) %></td></tr><BR><tr><td>time</td><td><%=
arrText(3) %></td></tr><BR><tr><td>change</td><td><%=
arrText(4) %></td></tr><BR><tr><td>open</td><td><%=
arrText(5) %></td></tr><BR><tr><td>high</td><td><%=
arrText(6) %></td></tr><BR><tr><td>low</td><td><%=
arrText(7) %></td></tr><BR><tr><td>volume</td><td><%=
arrText(8) %></td></tr><BR></table> <BR>Set objFSO =
Nothing<BR>%><BR><table><BR><tr><td>description</td><td>latest
figure</td><tr><BR><tr><td>symbol</td><td><%=
arrText(0) %></td></tr><BR><tr><td>last price</td><td><%=
arrText(1) %></td></tr><BR><tr><td>date</td><td><%=
arrText(2) %></td></tr><BR><tr><td>time</td><td><%=
arrText(3) %></td></tr><BR><tr><td>change</td><td><%=
arrText(4) %></td></tr><BR><tr><td>open</td><td><%=
arrText(5) %></td></tr><BR><tr><td>high</td><td><%=
arrText(6) %></td></tr><BR><tr><td>low</td><td><%=
arrText(7) %></td></tr><BR><tr><td>volume</td><td><%=
arrText(8) %></td></tr><BR></table> </P>
<<<----- Return to
Asp/VB Script Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Microsoft .Net Interview Questions
for more Microsoft
.Net Interview Questions with Answers.
Check
.Net Database Interview
Questions for more .Net Database Interview Questions with answers
Check
Job Interview Questions
for more Interview Questions with Answers
|