Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am new to perl. I have to convert the format of data as follows: Existing data format: (Please note that actual data contains more number of rows and colmns.. and not pre-defined)
----------------------- 1 2 3 a b c x y z -----------------------
The data format I need is:
----------------------- 1 a x 2 b y 3 c z -----------------------
I am going to use the new formatted data for an input to create graphs. I have all the necessary modules installed but this logic (I know it is not very complicated, but I am not getting it). Please advice how to take it forward. My final objective is to get the data in variable in somthing similar to following:
my @data = (['1','a','x' ], ['2','b','y' ], ['3','c','z' ]);
Please help.
=============================
Folks, The fact is that I am totally lost now :-) My objective was/is: To read a flat file which has SAR (system activity reporter) data and then to generate the graph using that data. I have module for graph but the problem here is the data needs to be transversed (row-> columns). My data looks like:
17:12:41 0 0 0 100 17:12:42 0 1 0 99 17:12:43 0 0 0 100 : :
And for the graph creation, I need this data in following format:
17:12:41 17:12:42 17:12:43 : : ... ... ... 0 0 0 : : ... ... ... 0 1 0 : : ... ... ... 0 0 0 : : ... ... ... 100 99 100 : : ... ... ...
Finally, to get an array like below:
my @data = ( ['17:12:41','17:12:42','17:12:43'.........], ['0','1','0'.........], ['0','0','0'.........], ['100','99','100'.....]);

In reply to How to swap rows with columns? by perl_geek

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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: (7)
    As of 2021-01-17 15:03 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?