Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by Kanji (Parson)
on Sep 26, 2010 at 20:24 UTC ( #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.


Comment on Re: transforming XY data to X and Multiple Y column data?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-08-27 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (235 votes), past polls