Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: transforming XY data to X and Multiple Y column data?

by Kanji (Parson)
on Sep 26, 2010 at 20:24 UTC ( [id://862117]=note: print w/replies, xml ) Need Help??


in reply to transforming XY data to X and Multiple Y column data?

You could try a more complex data structure.

A something of somethings of arrays should do the trick, such as an array of arrays of arrays:-

@id = ( [ [ ], # id1-0 [ ], # id2-0 [ 0, 0, 0 ], # id3-0 ], [ [ 90, ], # id1-1 [ 70, ], # id2-1 [ ], # id3-1 ], # ... );

...or an array of hashes of arrays:-

@id = ( { id3 => [ 0, 0, 0 ], }, { id1 => [ 90, ], id2 => [ 70, ], }, # ... );

...or even a hash of hashes of arrays:-

%id = ( 0 => { id3 => [ 0, 0, 0 ], }, 1 => { id1 => [ 90, ], id2 => [ 70, ], }, # ... );

Without knowing more about your input data, it's hard to say which of those will best suit your needs (or if something else is more appropriate or possible), but the of arrays part will at least do away with the issue of duplicates.

    --k.


Edit: Fixed typos in examples.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-20 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found