Avatar of jlcannon
jlcannon
 asked on

Data from CSV to webpage in ASP

I have a program that periodicly writes out a .CSV file named data.csv to a specified directory. the amount of data never changes just the figures in the data. I want to be able to then pull that data into an .asp webpage table using vb script. my problem is that the program writes a new .csv file everytime and i cannot send the data to a specified file with a named range so i can use it as a table. Is there a way for me to pull the data without having a named range. just pull all the data and arrange it once in the ASP?
VB ScriptASPWeb Languages and Standards

Avatar of undefined
Last Comment
jlcannon

8/22/2022 - Mon
Big Monty

yup absolutely, it's pretty straightforward. if you post your code I can help you translate it over to an asp page.
jlcannon

ASKER
right now I have no code. In the past I have used code like this:
<%@ Language=VBScript %>
<!--#include file="includes/adovbs.inc"-->
<%

	vXlsFile = "virtual/documents/TechReport/GetIP21Data.xlsm"

	
vXlsFile = Server.Mappath(vXlsFile)

		ExcelConnString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
		"Data Source=" & chr(34) & vXlsFile & chr(34) & ";" & _
		"Extended Properties=" & chr(34) & "Excel 12.0 Xml;HDR=YES;"& chr(34)

		'Open Database Connection
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open ExcelConnString 
%>
<html>
<head>
</head>
<body>
<%
				Sql = "SELECT * FROM tblData;"

				set RS = server.createobject("adodb.recordset")
	
	RS.open sql,Conn,adOpenForwardOnly,adLockReadOnly 
	
	if rs.bof and rs.eof then
		response.write "<br>No Records Returned!"
	else	
		Rs.Movefirst

%>

<table width="100%" border="1" cellpadding="0" cellspacing="0" class="stats-table">
<tr>	
      <th id="dailyInclude" style="width: 289px">&nbsp;</th>
      <th id="monthCOL" style="width: 244px">Tag</th>
      <th id="YTDCOL" style="width: 359px">Value</th>
      
							
</tr>
<%
do while not rs.eof
%>					
<tr>
<td class="rowType" style="width: 289px">Freeport</td>
<td align="center" style="width: 244px"><%=RS.Fields("TagName")%></td>
<td align="center" style="width: 359px"><%=RS.Fields("InputValue")%></td>
<%
	rs.movenext
loop
rs.close
set rs = nothing
%>

<%								
end if
Conn.Close
set conn = nothing

%>
</tr>
</table>
</body>

</html>

Open in new window

my issue is that I will not have that named range called tblData to use like a data table so dont know how to handle pulling the data in.
Scott Fell

Lets say the data layout is

Name, Email, Phone

and your data looks like

mike, mike@someplace.com, 1111111111

You would can parse each line using the split function.

line="mike, mike@someplace.com, 1111111111"
arrLine=split(line,",")
Name=arrLine(0)
Email=arrLine(1)
Phone=arrLine(2)

<table>
<tr><td>Name</td><td>Email</td><td>Phone</td></tr>
<%
line="mike, mike@someplace.com, 1111111111"
arrLine=split(line,",")
Name=arrLine(0)
Email=arrLine(1)
Phone=arrLine(2)
%>
<tr><td><%=Name%></td><td><%=Email%></td><td><%=Phone%></td></tr>
</table>

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Big Monty

where is the data coming from originally? you mention you write it out to  a csv file, but where does that data come from? is it pulled from a DB? if so, please post that code.
jlcannon

ASKER
i follow except on place. the line="mike,mike@someplace,111111"
is that meaning i will have to do that for everyline of data? I am confused the data will be in 2 columns and will look similar to this:

SPH_626abo,2.2256
SPO_8R39G,55.235
GRP_URG43,795.24

the name of the file will be test.csv so using your method above would I have to have a line like line="SPH_626abo,2.2256"
              line="SPO_8R39G,55.235"
              line="GRP_URG43,795.24"
for each row of data in the csv or how would I implement this?
jlcannon

ASKER
the data is pushed to the csv from a program called AspenTech IP21
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Robberbaron (robr)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jlcannon

ASKER
excellent, what I was looking for. Have googled this many times but never saw codeproject as a website.