> A snippet of the problem is here. The terms in file as > tab delim manner.
[data cut] > Now my question is to enrich members that have identical lineage with > different leaf. 'i.e': a b c d - van suv. Hi Srinivas, You're starting to use the vocabulary of tree data structures here. Let's clarify what you mean by: > I have two terms in this path and I am not happy with two. I wish to > have more. I think you mean "I have two descendent leaves at this point ...", in which case your next statement: > Then: a b c - car, van, truck, SUV and 18-wheeler (automobiles that > travel on road). I am happy with this grouping and I enriched more items > if I walk on lienage : (a-b-c) sounds like traversing up from your current node up to the parent node. In your example, this expands the descendent leaves to include those other elements. > Is there a way to automate this problem. I would strongly recommend not thinking about this as a text file problem, but as a data structure problem. Trying to do this by messing with lines and tabs seems to me like asking to turn a simple problem into a difficult one. The fact that the data that you have is in a text file should be treated as an accident more than anything: nothing binds you to try to solve your problem by slogging through with the original data representation. The problem becomes much clearer if you're dealing with trees: http://en.wikipedia.org/wiki/Tree_data_structure in which case you can use the vocabulary of tree traversal to make the problem very simple. I might be misundestanding what you're sying but it sounds like you're just asking for parent node traversal, which is a fundamental operation on trees. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor