[Chicago-talk] Building a hierarchy

David Young davidy at nationalcycle.com
Wed Mar 16 09:48:12 PDT 2011


>> 2) how to traverse the array without knowing my indexes, i.e. go one
level up, go one level down

Should be pretty easy to implement using recursion.  If you come across a
new line and it's a different "type" of prefix, recurse down if it looks
like a lower level (a simple conditional or regex test), otherwise "return"
to the previous level and let that level continue walking the hierarchy.

ydy

*David J. Young*
IT Director
* <http://www.nationalcycle.com> National Cycle, Inc.*
*office +1-*708-343-0400 x103
davidy at nationalcycle.com



On Wed, Mar 16, 2011 at 11:31 AM, Jay Strauss <me at heyjay.com> wrote:

> Hi,
>
> I need to build a hierarchy out of some data to load into a RDBMS.  The
> data looks like below.  I need to convert it to more like:
>
> code, desc, parent_code
>
> (where code is like "193200000X")
>
> I'm struggling.
>
> I think I could do this in a rigid manner by saying I have 4 indexes or
> levels:
> upper case roman
> lower case alpha
> lower case roman
> numeric
>
> and keeping track where I am, and I the parent one level above.
>
> I'd like to do it flexibly, without having to know how many levels in
> advance (I get similarly structured data with # of levels and info from time
> to time).
>
> But I don't know:
>
> 1) whats the best structure for this (I'm thinking an array of arrays)
> 2) how to traverse the array without knowing my indexes, i.e. go one level
> up, go one level down
>
> Can anyone suggest ways to skin this cat?
>
> Thanks
> Jay
>
>
> I. Individual or Groups (of Individuals)
> a. Group
> i. Multi-Specialty  - 193200000X
> ii. Single Specialty  - 193400000X
> b. Allopathic & Osteopathic Physicians
> i. Allergy & Immunology - 207K00000X
> 1. Allergy - 207KA0200X
> 2. Clinical & Laboratory Immunology - 207KI0005X
> ii. Anesthesiology - 207L00000X
> 1. Addiction Medicine - 207LA0401X
> 2. Critical Care Medicine - 207LC0200X
> 3. Hospice and Palliative Medicine - 207LH0002X
> 4. Pain Medicine - 207LP2900X
> 5. Pediatric Anesthesiology - 207LP3000X
> iii. Clinical Pharmacology - 208U00000X
> iv. Colon & Rectal Surgery - 208C00000X
> v. Dermatology - 207N00000X
> 1. Clinical & Laboratory Dermatological Immunology - 207NI0002X
> 2. Dermatopathology - 207ND0900X
> 3. MOHS-Micrographic Surgery - 207ND0101X
> 4. Pediatric Dermatology - 207NP0225X
> 5. Procedural Dermatology - 207NS0135X
> vi. Electrodiagnostic Medicine - 204R00000X
> vii. Emergency Medicine - 207P00000X
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20110316/923f9755/attachment.html>


More information about the Chicago-talk mailing list