Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: XLSX to CSV with high ASCII characters

by poj (Abbot)
on Aug 26, 2017 at 18:44 UTC ( [id://1198077]=note: print w/replies, xml ) Need Help??


in reply to XLSX to CSV with high ASCII characters

Does this work ?

#!/usr/bin/perl use strict; use Text::CSV; my $outputFile = 'bar.csv'; my $csv = Text::CSV->new ( { binary => 1, eol => "\n" } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, ">:encoding(utf-8)", $outputFile or die "$outputFile: $!"; $csv->print ($fh, ['Nicolás',123]); close $fh or die "$outputFile: $!";
poj

Replies are listed 'Best First'.
Re^2: XLSX to CSV with high ASCII characters
by apu (Sexton) on Aug 26, 2017 at 19:39 UTC
    That outputs
    Nicolás,123

      It that what it shows in Excel ?

      poj

        Excel shows Nicholás properly, as does the CSV/text output of xls2csv. But my script, and your test script, both create output with á as á

        And, if I open bar.csv in Excel, I get Nicolás

        $ cat bar.pl #!/usr/bin/perl use strict; use Text::CSV; my $outputFile = 'bar.csv'; my $csv = Text::CSV->new ( { binary => 1, eol => "\n" } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, ">:encoding(utf8)", $outputFile or die "$outputFile: $!"; $csv->print ($fh, ['Nicolás',123]); close $fh or die "$outputFile: $!"; $ cat bar.csv Nicolás,123

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1198077]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found