Skip to content

Instantly share code, notes, and snippets.

@lth2h
Created September 10, 2014 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lth2h/5b12166a2d49c862cbef to your computer and use it in GitHub Desktop.
Save lth2h/5b12166a2d49c862cbef to your computer and use it in GitHub Desktop.
csv2html.pl
#!/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