-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapp.asp
52 lines (48 loc) · 1.61 KB
/
app.asp
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
<%@ Language= "VBScript" %>
<html>
<head>
<title>Company Data</title>
</head>
<body>
<h1>Company Data</h1>
<table border="1">
<tr>
<th>Company</th>
<th>City</th>
<th>Last Updated</th>
</tr>
<%
' Path to our data source (CSV file)
' In a real-world scenario, we would connect to a database instead
' Data format: Company, City, Last Updated
Dim csvPath
csvPath = Server.MapPath("data.csv")
' Read the contents of the CSV file
Dim fso, file, csvContent, lines, i, lineData
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(csvPath) Then
Set file = fso.OpenTextFile(csvPath, 1, False)
csvContent = file.ReadAll
file.Close
Set file = Nothing
' Split the content into lines
lines = Split(csvContent, vbCrLf)
' Process each line except the first one (header)
For i = 1 To UBound(lines)
lineData = Split(lines(i), ",")
If UBound(lineData) >= 2 Then ' Ensure there are enough data elements
Response.Write "<tr>"
Response.Write "<td>" & lineData(0) & "</td>"
Response.Write "<td>" & lineData(1) & "</td>"
Response.Write "<td>" & lineData(2) & "</td>"
Response.Write "</tr>"
End If
Next
Else
Response.Write "CSV file not found."
End If
Set fso = Nothing
%>
</table>
</body>
</html>