<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    I would try very hard to find an alternative source data format
    (perhaps with level-dependent indentation?) if at all possible
    before spending a lot of time trying to parse this one because it's
    ambiguous.<br>
    <br>
    Consider an item on line "i." after an item on line "h.". Depending
    on the type of the subsequent line, you may ("ii.") or may not
    ("V.") be able to determine what type of line the "i." item is.<br>
    <br>
      - Brian<br>
    <br>
    On 2011-03-16 11:31, Jay Strauss wrote:
    <blockquote
      cite="mid:AANLkTinCEedxzT+_cr0J0e_aZk3EmMQEkGKiupU5qdv1@mail.gmail.com"
      type="cite">Hi,
      <div><br>
      </div>
      <div>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:</div>
      <div><br>
      </div>
      <div>code, desc, parent_code</div>
      <div><br>
      </div>
      <div>(where code is like "193200000X")</div>
      <div><br>
      </div>
      <div>I'm struggling.</div>
      <div><br>
      </div>
      <div>I think I could do this in a rigid manner by saying I have 4
        indexes or levels:</div>
      <div>upper case roman</div>
      <div>lower case alpha</div>
      <div>lower case roman</div>
      <div>numeric</div>
      <div><br>
      </div>
      <div>and keeping track where I am, and I the parent one level
        above.</div>
      <div><br>
      </div>
      <div>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).  </div>
      <div><br>
      </div>
      <div>But I don't know:</div>
      <div><br>
      </div>
      <div>1) whats the best structure for this (I'm thinking an array
        of arrays)</div>
      <div>2) how to traverse the array without knowing my indexes, i.e.
        go one level up, go one level down</div>
      <div><br>
      </div>
      <div>Can anyone suggest ways to skin this cat?</div>
      <div><br>
      </div>
      <div>Thanks</div>
      <div>Jay</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>
        <div>I.<span class="Apple-tab-span" style="white-space: pre;"> </span>Individual
          or Groups (of Individuals)</div>
        <div>a.<span class="Apple-tab-span" style="white-space: pre;"> </span>Group
           </div>
        <div>i.<span class="Apple-tab-span" style="white-space: pre;"> </span>Multi-Specialty
           - 193200000X</div>
        <div>ii.<span class="Apple-tab-span" style="white-space: pre;">
          </span>Single Specialty  - 193400000X</div>
        <div>b.<span class="Apple-tab-span" style="white-space: pre;"> </span>Allopathic
          & Osteopathic Physicians  </div>
        <div>i.<span class="Apple-tab-span" style="white-space: pre;"> </span>Allergy
          & Immunology - 207K00000X</div>
        <div>1.<span class="Apple-tab-span" style="white-space: pre;"> </span>Allergy
          - 207KA0200X</div>
        <div>2.<span class="Apple-tab-span" style="white-space: pre;"> </span>Clinical
          & Laboratory Immunology - 207KI0005X</div>
        <div>
          ii.<span class="Apple-tab-span" style="white-space: pre;"> </span>Anesthesiology
          - 207L00000X</div>
        <div>1.<span class="Apple-tab-span" style="white-space: pre;"> </span>Addiction
          Medicine - 207LA0401X</div>
        <div>2.<span class="Apple-tab-span" style="white-space: pre;"> </span>Critical
          Care Medicine - 207LC0200X</div>
        <div>3.<span class="Apple-tab-span" style="white-space: pre;"> </span>Hospice
          and Palliative Medicine - 207LH0002X</div>
        <div>4.<span class="Apple-tab-span" style="white-space: pre;"> </span>Pain
          Medicine - 207LP2900X</div>
        <div>
          5.<span class="Apple-tab-span" style="white-space: pre;"> </span>Pediatric
          Anesthesiology - 207LP3000X</div>
        <div>iii.<span class="Apple-tab-span" style="white-space: pre;">
          </span>Clinical Pharmacology - 208U00000X</div>
        <div>
          iv.<span class="Apple-tab-span" style="white-space: pre;"> </span>Colon
          & Rectal Surgery - 208C00000X</div>
        <div>v.<span class="Apple-tab-span" style="white-space: pre;"> </span>Dermatology
          - 207N00000X</div>
        <div>1.<span class="Apple-tab-span" style="white-space: pre;"> </span>Clinical
          & Laboratory Dermatological Immunology - 207NI0002X</div>
        <div>2.<span class="Apple-tab-span" style="white-space: pre;"> </span>Dermatopathology
          - 207ND0900X</div>
        <div>3.<span class="Apple-tab-span" style="white-space: pre;"> </span>MOHS-Micrographic
          Surgery - 207ND0101X</div>
        <div>
          4.<span class="Apple-tab-span" style="white-space: pre;"> </span>Pediatric
          Dermatology - 207NP0225X</div>
        <div>5.<span class="Apple-tab-span" style="white-space: pre;"> </span>Procedural
          Dermatology - 207NS0135X</div>
        <div>vi.<span class="Apple-tab-span" style="white-space: pre;">
          </span>Electrodiagnostic Medicine - 204R00000X</div>
        <div>vii.<span class="Apple-tab-span" style="white-space: pre;">
          </span>Emergency Medicine - 207P00000X</div>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Chicago-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/chicago-talk">http://mail.pm.org/mailman/listinfo/chicago-talk</a></pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, GNU/Linux, open source, and custom
software solutions for business and beyond
Phone: 877.367.8837 x1  <a class="moz-txt-link-freetext" href="http://www.kappacs.com">http://www.kappacs.com</a></pre>
  </body>
</html>