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

Re: perl group by and sort from a csv input file -- oneliner and lazy learning

by Discipulus (Canon)
on Jul 27, 2017 at 11:05 UTC ( [id://1196158]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    
    perl -F"," -lanE "$h{join ',',@F[0,1]}+=$F[2]}{map{say $_.','.$h{$_}}s
    +ort keys %h"  sample.csv
    ...
    3211112,101,3.2
    3211113,100,5.2
    
  2. or download this
    perl -MO=Deparse -F"," -lanE "$h{join ',',@F[0,1]}+=$F[2]}{map{say $_.
    +','.$h{$_}}sort keys %h"  sample.csv
    
    ...
    }
    -e syntax OK
    
  3. or download this
    perl -MO=Deparse -e 1
    '???';
    ...
    }
    -e syntax OK
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-20 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found