-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflat2html.pl
More file actions
executable file
·46 lines (32 loc) · 788 Bytes
/
flat2html.pl
File metadata and controls
executable file
·46 lines (32 loc) · 788 Bytes
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
#!/usr/bin/perl -w
if(scalar(@ARGV) != 2 && scalar(@ARGV) != 1) {
print "Convert the specified flat file into html table\n";
die "Usage: ~ <in.csv> [with_header]\n";
}
use Flat;
my($file);
if(scalar(@ARGV) == 2) {
$file = Flat->new($ARGV[0], $ARGV[1]);
}
else {
$file = Flat->new1($ARGV[0]);
}
print "<table border=1>\n";
if($file->hasHeader()) {
my(@fldNames) = $file->getFieldNames();
print "<tr>";
foreach $fn (@fldNames) {
print "<th>$fn</th>";
}
print "</tr>\n";
}
my(@data) = $file->getDataArray();
my($numOfCols) = $file->getNumOfColumns();
for(my($i) = 0; $i < scalar(@data); $i++) {
print "<tr>";
for(my($j) = 0; $j < $numOfCols; $j++) {
print "<td>$data[$i][$j]</td>";
}
print "</tr>\n";
}
print "</table>\n";