Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: parsing text files continued

by AltBlue (Chaplain)
on Jul 19, 2008 at 12:39 UTC ( [id://698807]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -F, -lane '@F % 2 and push @D, [@F] or push @{$D[-1]}, pop @F; 
    +}{ $,=q{,}; print @{$_} for @D' input.txt
    
  2. or download this
    1/3/2007 12:20:01 AM,12.588309,9.432586,20:0.196329,7.418672,3.616305,
    +2.066482,6.873061,0.784989,1.859894,3.249620,0.450952,0.305768,0.8234
    +02
    1/3/2007 12:49:22 AM,10.958312,13.644527,41:0.483233,7.027840,4.222601
    +,0.305821,7.443877,1.552915,1.202711,5.285398,0.233119,0.425521,0.560
    +862
    
  3. or download this
    $ perl -MData::Dumper -F, -lane '@F % 2 and ($k)=@F or push @{$D{$k}},
    + @F; }{ $D{$_} = {@{$D{$_}}} for keys %D; print Dumper \%D' input.txt
    
  4. or download this
    $VAR1 = {
              '1/3/2007 12:49:22 AM' => {
    ...
                                          'SearchLoad' => '9.432586'
                                        }
            };
    

Log In?
Username:
Password:

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

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

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.