Subject: | No result and no error with caracter with accent |
Hi,
I would like to convert csv file into xml file.
Thank you so much for csv2xml.pl but I've got a problem with it.
The caracter such "é, è, or à" does not generate the xml file.
And I even don't have an error message.
Thank you for helping me.
I've tried to change encoding with ISO-8859-1 but it doesn't have any
effect.
For information Perl version is 5.8.7 and the OS is Solaris.
Subject: | csv2xmlbis.pl |
#!/usr/local/bin/perl
use XML::CSVINPUT;
use Getopt::Long;
my %option = ('defaultdelim' => ';');
GetOptions
(
'infile=s' => \$option{csvin},
'outfile=s' => \$option{xmlout},
'delim=s' => \$option{delim},
);
unless (defined ($option{csvin} && $option{xmlout}))
{&USAGE();
exit;
}
unless (defined $option{delim})
{$option{delim} = $option{defaultdelim};
}
eval{
$default_obj_xs = Text::CSV_XS->new({sep_char => $option{delim}}, error_out => '1');
my $obj = XML::CSVINPUT->new({csv_xs => $default_obj_xs});
my $num = $obj->parse_doc($option{csvin}, {'headings' => 1, 'sub_char' => "_"});
$obj->declare_xml({version => '1.0', encoding=> 'ISO-8859-1', standalone => 'yes'});
#$obj->declare_doctype({source => 'PUBLIC', location1 => '-//Netscape Communications//DTD RSS 0.90//EN', location2 => 'http://my.netscape.com/publish/formats/rss-0.91.dtd'});
$obj->print_xml($option{xmlout}, {format => " ", file_tag => "dsScheduleData", parent_tag => "Activity"});
#if($XML::CSV::csvxml_error) != ""
#{print "erreur : $XML::CSV::csvxml_error"
#}
};
if($@)
{print "not ok 4: $@\n";
$loaded = 0;
undef($@);
}
else
{print "OK $@\n";
}
########################################################
sub USAGE
{
print <<EOF
Options requises :
==================
-i FichierCSV1,FichierCSV2 si plusieurs fichiers csv ou -i FichierCSV
-o NomDuFichierXLS
-d ";" pour le delimiteur
Exemple :
---------
csv2xls.pl -i file1.csv,file2.csv,file3.csv -o file1.xls -d ";"
EOF
;
}
Subject: | dataout.xml |
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<dsScheduleData>
<Input_Reference>
<id>1</id>
<datetime>2010-12-17T10:06:18+489837</datetime>
</Input_Reference>
<Activity>
<Colonne_1></Colonne_1>
<Colonne_2></Colonne_2>
</Activity>
</dsScheduleData>
Subject: | DataFrench.csv |
Message body not shown because it is not plain text.