Solved

parse data from csv file to webpage

Posted on 2014-03-12
3
482 Views
Last Modified: 2014-03-12
I have a csv file that has 7 columns and 1974 rows. this csv file is automatically put in the folder every 5 minutes and the old one is just overwritten. I have no way of making this a template file so what i need to do is get this data into something that will allow me to pull data out of it and post to a webpage metric table. column A is the column that had the "name" i would be looking for to decide what data I am wanting to post. The webpage would be an ASP page and I am familier with using vbscripting code and pulling data that way. I have attached a sample of how the CSV file is formatted.
testWeb.csv
0
Comment
Question by:jlcannon
  • 2
3 Comments
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 500 total points
ID: 39923753
Try this

<%
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\inetpub\wwwroot\folder\testWeb.csv", ForReading)
response.write "<table>"
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    arrFields = Split(strLine, ",")
    
	response.write "<tr><td>"&arrFields(0)& "</td><td>"&arrFields(1)&"</td><td>"&arrFields(2)&"</td><td>"&arrFields(3)&"</td></tr>"
 
Loop

objFile.Close
%>

Open in new window

0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39923758
If you need to filter the first column of what I posted, you could do

<%
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\inetpub\wwwroot\folder\testWeb.csv", ForReading)
response.write "<table>"
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    arrFields = Split(strLine, ",")
    
    if arrFields(0)="Greek" then
	response.write "<tr><td>"&arrFields(0)& "</td><td>"&arrFields(1)&"</td><td>"&arrFields(2)&"</td><td>"&arrFields(3)&"</td></tr>"
 end if
Loop

objFile.Close
%>

Open in new window

0
 

Author Closing Comment

by:jlcannon
ID: 39923878
Thank you this will help get me on my way. Still have hurdles with this data but this is exactly the start I needed.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now