[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Import CSV File to HTML Table

Posted on 2014-08-27
5
Medium Priority
?
12,309 Views
Last Modified: 2014-09-02
Hi

 Our warehouse team would like displayed on a big telly mounted on the wall the packing stats for each individual packer.

 We can export as a CSV or tab delimited text file the packer's username, full name and number of parcels despatched from our ERP system every minute so that the file has up-to-date data in it.  What I need to do is figure out a way of presenting this data on the big screen ideally in a nicely formatted table.

 Does anyone know of a simple way of doing this (I have no experience of writing any sort of code)?  Or a third party software solution than can do such a thing?

I have attached an example output file from our system.

Many thanks
pick.csv
0
Comment
Question by:admincbf
5 Comments
 
LVL 34

Expert Comment

by:Big Monty
ID: 40289122
Your best bet is to use some kind of server side language to do this, although there are straight JavaScript solutions out there, which, IMO, are not as straightforward to follow. There are a lot of examples on the net for php, .net,, classic asp, etc. Once you decide on a technology, I can better help you.
0
 
LVL 3

Expert Comment

by:AndrewSwingewood
ID: 40289767
Is your ERP database accessible via ODBC?  If it is, the best way may be to interface directly into the tables using SQL to extract the data directly to a JSP page and just refresh the page automatically every minute or so.  Much more efficient than parsing and displaying CSV data all the time.
What software/database hosts the ERP system?  Is it Oracle, MS SQL Server or something similar?
0
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 40291715
Given this is internal, export the csv to an web accessible folder so that your html page can access it.

Then just use the <meta> tag with the refresh attribute to reload the page every N second.

The demo below using jQuery and a plugin called Papa Parse for parsing csv files (http://papaparse.com/)

I modified your pick.csv to comma separated as it was space separated.

<!DOCTYPE html>
<html>
<head>
	<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
	<script src="http://papaparse.com/resources/js/papaparse.js"></script>
	<script src="main.js"></script>
	<link rel="stylesheet" href="main.css">
  <meta charset="utf-8">
<meta http-equiv="refresh" content="120"><!-- REFRESH EVERY 2 minutes -->
  <title>JS Bin</title>
</head>
<body>
	<table id="results">
		<tbody>
		</tbody>
	</table>
	
</body>
</html>

Open in new window


javascript:
$(function() {
	Papa.parse("pick.csv", {
		download: true,
		complete: function(results) {
			console.log("Remote file parsed!", results.data);
			$.each(results.data, function(i, el) {
				var row = $("<tr/>");
				row.append($("<td/>").text(i));
				$.each(el, function(j, cell) {
					if (cell !== "")
						row.append($("<td/>").text(cell));
				});
				$("#results tbody").append(row);
			});
		}
	});
});

Open in new window


CSS:
#results {
	width: 100%;
	border-collapse: collapse;
}
table, th, td {
	border: 1px solid black;
}

Open in new window

pick.csv
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 40291789
You might want to look into any hooks the ERP system may have.  Sometimes there area API's and you can use javascript to hit that ERP and send some data to your screen.   Otherwise, Rob's solution is the way to go and will probably be the easiest in the end.
0
 
LVL 1

Author Closing Comment

by:admincbf
ID: 40297911
Thanks very much for the thorough solution
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

868 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