Revision: 24560
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 3, 2010 18:16 by bionic
Initial Code
#! /usr/bin/perl use warnings; use strict; use Text::CSV; # generate XML from CSV files # my $csv = Text::CSV->new( { binary => 1, # binary for utf8, latin1 etc sep_char => "\t" } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); $csv->eol(" "); binmode(STDIN, ":utf8"); binmode(STDOUT, ":utf8"); foreach (@ARGV) { open my $input, "<:encoding(utf8)", $_ or die "test.csv: $!"; print "<csv filename=\"$_\">"; while (my $colref = $csv->getline($input)) { print "<row>" . join("", map { "<cell>$_</cell>" } @$colref ) . "</row>\n"; } print "</csv>\n"; }
Initial URL
Initial Description
Useful perl snippet to convert csv docs to xml from Ankh on the freenode #xml irc channel
Initial Title
csv2xml perl version
Initial Tags
xml, csv
Initial Language
Perl