Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Moving data in a tree

by wade (Pilgrim)
on Jul 21, 2008 at 20:56 UTC ( #699149=note: print w/replies, xml ) Need Help??

in reply to Re: Moving data in a tree
in thread Moving data in a tree

Interesting. I'd have done this a little differently. When you are traversing the tree and you are done processing a node, check to see if it only has one leaf. If so, move the single leaf to its parent node (deleting children that have no leaves). The end result would be the same (i.e., branches with single leaves would get moved to the root) but this would allow nodes that wouldn't make it all the way to the root to be propagated as high as they could be.

Of course, that's not what the OP actually requested so I could be full, um...I could be wrong.


Replies are listed 'Best First'.
Re^3: Moving data in a tree
by hoffmann (Novice) on Jul 21, 2008 at 21:10 UTC
    Would it be possible to load the excel file as is, then run the perl script on it?

      In general, if I don't have a memory crisis, I'd:

      • read the whole file into a suitable data structure,
      • manipulate the data structure, and
      • write the data structure out to a new file.

      That makes things easier to code and, since you have before and after files, easier to check.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://699149]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2018-03-17 21:01 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.