Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: One Liner to double quote every field in a delimited file

by Tux (Monsignor)
on Jan 31, 2014 at 21:43 UTC ( #1072918=note: print w/ replies, xml ) Need Help??


in reply to One Liner to double quote every field in a delimited file

I am still testing, but the next release of Text::CSV_XS will offer that as

$ perl -MText::CSV_XS=csv -we'csv (in => csv (file => "file.csv"), out + => *STDOUT, always_quote => 1)'

I expect to release somewhere next week.

A longer one-liner that works with Text::CSV_XS right now is:

$ perl -MText::CSV_XS -we'$c=Text::CSV_XS->new;$a=$c->getline_all(\*AR +GV);$c->eol($/);$c->always_quote(1);$c->print(\*STDOUT,$_)for@$a' fil +e.csv

Enjoy, Have FUN! H.Merijn


Comment on Re: One Liner to double quote every field in a delimited file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-05 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls