Created
September 10, 2014 17:55
-
-
Save lth2h/5b12166a2d49c862cbef to your computer and use it in GitHub Desktop.
csv2html.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Text::xSV; | |
my $in = $ARGV[0] || "foo.csv"; | |
my $out = $ARGV[1] || "/tmp/out.html"; | |
open(FILE, "+>", $out) or die("Could not open $out"); | |
print FILE "<table>"; | |
my $csv = new Text::xSV; | |
$csv->open_file($in); | |
# $csv->read_header(); | |
while (my @fields = $csv->get_row()) { | |
print FILE "<tr>"; | |
foreach my $value (@fields) { | |
print FILE "<td>" . $value . "</td>"; | |
} | |
print FILE "</tr>\n"; | |
} | |
print FILE "</table>"; | |
close(FILE); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment