Display information from csv-datei in html page without web server
I have a problem that I will like someone here to help me. I have Perl Script giving me csv file information. his information:
DATA:
Number of compared parameters =7
Current number of systems = 56
Date = 20150617 1:00:13 p.m.
Considering that the values ββmay change. I like that his information is displayed in the html page. I don't want to use a web server for this. I was told that this is possible with javascript. I will love that someone here can help me.
for this reason I sent you my Perl Script and main page (html).
Perl code:
If you need to output your value to HTML file in a script this might help
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
use POSIX qw(strftime);
my $date_1 = strftime "%Y%m%d %H:%M:%S", localtime;
my $FileResult = 'result_1.csv';
open( my $FhResult, '>', $FileResult );
open my $fh, "<", "DATA.csv";
my ($h, $v) = (0, 0);
while (<$fh> ) {last if (/^\d+\s+\d{2}:\d{2}:\d{2}\s*$/)}
while (<$fh> ) {
next if (/^\s*$/);
if (/^default\b/) {
$h = 0 + grep {!/^(default)?$/} map {s/^\s+|\s+$//g; $_} split(/,/, $_);
} else {
$v++;
}
}
close($fh);
open FH ,">1.html";
print FH "
<html>
<head>
<meta charset=\"UTF-8\"/>
<title>SYSTEMRESULTS</title>
<link href=\"style.css\" type=\"text/css\" rel=\"stylesheet\"/>
</head>
<body>
<div id=\"section_1\">
<font face=\"arial\"><h1><a id=\"sec_1_0\">S</a>ystem <a id=\"sec_1_0\">P</a>arameter  <a id=\"sec_1_0\">C</a>ompare</h1></font>
</div>
<div id=\"section_3\">
<font face=\"arial\" size=\"+2\">Current number of systems: $v </font>
</div>
<div id=\"section_4\">
<font face=\"arial\" size=\"+2\">Number of compared parameters: $h </font>
</div>
<div id=\"section_5\">
<font face=\"arial\" size=\"+2\">Date: $date_1</font>
</div>
<div id=\"section_6\"><a href=\"file/result_1.csv\">NEXT<img src=\"aiga.png\"/></a></div>
</body>
<div id=\"footer\">
<p>© 2015 copyright</p>
</div>
</html>
";
close FH;
Output
1.html content:
System Parameter βCompare
Current number of systems: 56
Number of compared parameters: 7
Date: 20150617 1:00:13 p.m
source to share
Let your gem script write the file data.js
with the data you want. After that you can use it in the HTML file with <script src="data.js" ...>
and wherever you want with document.write(data['Number of compared parameters']);
.
var data = {
'Number of compared parameters': 7,
'Current number of systems': 56;
'Date': '20150617 1:00:13 p.m.'
};
source to share