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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

And here's one more (perhaps "ugly" :) option:

use strict; use warnings; my @col1 = split ' ', <DATA>; <DATA>; my @rows = map { my @row = split; \@row } <DATA>; my $i = 2; for my $col (@col1) { print "$col\t$_->[0]\t$_->[1]\t$_->[$i]\n" for @rows; $i++; } __DATA__ A C F SampleID Time ObsConc ObsConc ObsConc 5 24 2.27E+06 687.02 32521.94 5 168 1.92E+06 525.02 22198.44 5 12 2.94E+06 896.39 41331.61 5 -0.5 2.23E+06 942.34 40616.49 5 8 4.03E+06 1371.32 45863.69 6 24 1.02E+06 1057.89 46341.04 6 168 3.14E+06 4987.32 42166.08

Output:

A 5 24 2.27E+06 A 5 168 1.92E+06 A 5 12 2.94E+06 A 5 -0.5 2.23E+06 A 5 8 4.03E+06 A 6 24 1.02E+06 A 6 168 3.14E+06 C 5 24 687.02 C 5 168 525.02 C 5 12 896.39 C 5 -0.5 942.34 C 5 8 1371.32 C 6 24 1057.89 C 6 168 4987.32 F 5 24 32521.94 F 5 168 22198.44 F 5 12 41331.61 F 5 -0.5 40616.49 F 5 8 45863.69 F 6 24 46341.04 F 6 168 42166.08

Hope this helps!

Edit: My thanks to poj for pointing out that my script didn't properly generate the last column's values. This is fixed.


In reply to Re: format conversion, please help by Kenosis
in thread format conversion, please help by david_lyon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (9)
    As of 2015-07-05 21:18 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