Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: Lost in compressed encodings

by Tux (Canon)
on Apr 06, 2020 at 10:49 UTC ( [id://11115129]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Lost in compressed encodings
in thread Lost in compressed encodings

I would suggest using Text::CSV_XS to read/parse the CSV. It already knows how to deal with UTF-8.

It is capable of using a TAB as separation character:

use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => "\t", auto_dia +g => 1 }); my @headers = $csv->header ($in); # Read the docs, there are options p +ossible here while (my $row = $csv->getline ($in)) { # ... }

update: I realized later that Text::CSV_XS' csv function already supports gzip as part of the encoding attribute.

use Text::CSV_XS qw( csv ); use PerlIO::via::gzip; my $aoa = csv (in => "test.csv.gz", encoding => ":via(gzip)");

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

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

    No recent polls found