Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] 2/28/01 - Data Manipulation Problem

Expand Messages
  • Smith, Sheldon
    I would suggest 1. create a list @N containing all 50 field names my @N = qw( ADD_DT AVLIB CATNO CHOUT COPY ...); 2. When you hit a record, create a new
    Message 1 of 1 , Mar 1, 2001
    • 0 Attachment
      I would suggest
      1. create a list @N containing all 50 field names
      my @N = qw( ADD_DT AVLIB CATNO CHOUT COPY ...);
      2. When you hit a <REC> record, create a new hash %F.
      3. As you read each <#FIELD NAME record, the name is the hash key, the
      string is the hash value.
      4. When you reach the </REC> record,
      A. output the heading records,
      B. For each field name in @N, if the field is in %F (that is, if
      $F{$name} exists), use it; otherwise write a null string value
      C. output the trailing records.
      5. repeat

      Hope this helps

      -----Original Message-----
      From: Gorden-Ozgul, Patricia E [mailto:gorden@...]
      Sent: Wednesday, February 28, 2001 6:22 PM
      To: 'perl-beginner'
      Subject: [PBML] 2/28/01 - Data Manipulation Problem


      Hi List,

      I need help.

      The datafile I have contains tagged data items.
      Each record MUST contain identical tagged data items (In name and number).
      In fact, probability is great that each record will be missing one or more
      tagged data items.
      Each record should contain exactly fifty(50) tags which I can identify.
      If there is a tag missing from a record, it should be added with a NULL
      string value.

      I'm sure that there is grep/sed/awk/perl solution out there for my problem.
      Are you willing to provide me with a possible solution?

      Sample data:

      <REC>
      <COPY>
      <#FIELD NAME = ADD_DT>"string"</#FIELD>
      <#FIELD NAME = AVLIB>"string"</#FIELD>
      <#FIELD NAME = CATNO>"string"</#FIELD>
      <#FIELD NAME = ADD_DT>"string"</#FIELD>
      <#FIELD NAME = CHOUT>"string"</#FIELD>
      <#FIELD NAME = COPY>"string"</#FIELD>
      ...(more fields possible)
      </COPY>
      </REC>

      I sincerely appreciate any help. Even a lead-in would brighten my day!
      Pat

      __________________________________________________
      Pat Gorden-Ozgul BNL-ISD Systems
      gorden@... 631-344-5159
    Your message has been successfully submitted and would be delivered to recipients shortly.