Is there a program or function that exists (I realize i will probably end up writing my own, but whatever) that I can use to create a category hierachy out of text ? For example, I want:

Top 0
Cat 30
Cat 94
Cat 29
Cat 100
Cat 23
Cat 231
Cat 232
Cat 248
Cat 293
Cat 982
Cat 24


If anyone has some code for this, it'd be greatly appreciated.

Josh