Appending to columns

Discussion in 'Perl Misc' started by Chandramohan Neelakantan, Oct 14, 2003.

  1. hello
    The following is the code Ive been using to parse hardware desing
    rules from a ASCII file based on ideas from Gunnar Hjalmarsson and
    Matija Papec.




    ******************************************************************


    # A sample rules page is in $contents

    $contents = "10.01 Width of n+buried layer
    3.6
    1, R1


    10.02 Enclosure of oxide isolation (L35)
    0.3 all devices,
    1, R7

    except power npn

    CEBEC


    10.03 Distance to scribe line (inside DIE AREA)
    20.0
    1, R2

    Note: N+ buried layer is NOT allowed in scribe line
    areas.";



    # Begin Parsing

    while ( $contents =~
    /(\d+(?:\.\d+)+)
    \s+
    ([\w\-\s]+[\w\-]\s{1,3}(.*?)) # Description
    \s+
    (\d+.*?\s{3}) # Dimensions
    \s{1,3}
    (.*?) # Devices
    \s{6,}
    (\d,\s[A-Z]\d) # Fig

    /gix)






    {


    print $1,"\n"; # Rule No
    print $2,"\n"; # Description
    print $4,"\n"; # Dimension
    print $5,"\n"; # Apllicable Devices
    print $6,"\n"; # Figure

    $contents = $';


    $contents =~ /(.*?)(?=\d+(?:\.\d+)+|$)/sg;
    $contents = $';






    print "******************************************************************\n";
    }

    ******************************************************************




    Each rule has

    1. A Rule Number
    2. A Rule description ( Additional note to this column *may* appear in
    subsequent lines)
    3. Dimension info
    4. Applicable devices ( may be blank or words for this column could
    appear in subsequent lines
    5. Figure



    There are many instances where it is difficult to associate text to
    its appropriate column.

    For example,

    ******************************************************************
    10.02 Enclosure of oxide isolation (L35)
    0.3 all devices,
    1, R7

    except power npn

    CEBEC
    ******************************************************************

    is a rule where the Applicable devices column entry is 'all devices
    except power npn CEBEC'. Since the entry is spanned over a few lines I
    find it difficult to associate it with the appropriate column. Also ,
    the entry for this column may be empty


    Here is another example:


    ******************************************************************

    10.03 Distance to scribe line (inside DIE AREA)
    20.0
    1, R2

    Note: N+ buried layer is NOT allowed in scribe line
    areas.

    ******************************************************************

    The Note actually belongs to the Description column.


    I need to find a way in which I can attach each of the text
    appearing in subsequent lines of a rule to its subsequent collumn.
    PLease note that there may or may not be Notes and Applicable devices
    column entry to each rule .


    I think the code mentioned above is mostly right. I need help in
    attching the text to its appropriate column.

    I have uploaded a copy of a sample text file here
    http://geocities.com/knchandramohan/1920.zip


    Help appreciated !

    MAny thanks
    CM
     
    Chandramohan Neelakantan, Oct 14, 2003
    #1
    1. Advertising

  2. Chandramohan Neelakantan

    Anand Guest

    I don't know if this is what you want .. you can use 'format' for
    customized output.

    --Anand


    Chandramohan Neelakantan wrote:

    > hello
    > The following is the code Ive been using to parse hardware desing
    > rules from a ASCII file based on ideas from Gunnar Hjalmarsson and
    > Matija Papec.
    >
    >
    >
    >
    > ******************************************************************
    >
    >
    > # A sample rules page is in $contents
    >
    > $contents = "10.01 Width of n+buried layer
    > 3.6
    > 1, R1
    >
    >
    > 10.02 Enclosure of oxide isolation (L35)
    > 0.3 all devices,
    > 1, R7
    >
    > except power npn
    >
    > CEBEC
    >
    >
    > 10.03 Distance to scribe line (inside DIE AREA)
    > 20.0
    > 1, R2
    >
    > Note: N+ buried layer is NOT allowed in scribe line
    > areas.";
    >
    >
    >
    > # Begin Parsing
    >
    > while ( $contents =~
    > /(\d+(?:\.\d+)+)
    > \s+
    > ([\w\-\s]+[\w\-]\s{1,3}(.*?)) # Description
    > \s+
    > (\d+.*?\s{3}) # Dimensions
    > \s{1,3}
    > (.*?) # Devices
    > \s{6,}
    > (\d,\s[A-Z]\d) # Fig
    >
    > /gix)
    >
    >
    >
    >
    >
    >
    > {
    >
    >
    > print $1,"\n"; # Rule No
    > print $2,"\n"; # Description
    > print $4,"\n"; # Dimension
    > print $5,"\n"; # Apllicable Devices
    > print $6,"\n"; # Figure
    >
    > $contents = $';
    >
    >
    > $contents =~ /(.*?)(?=\d+(?:\.\d+)+|$)/sg;
    > $contents = $';
    >
    >
    >
    >
    >
    >
    > print "******************************************************************\n";
    > }
    >
    > ******************************************************************
    >
    >
    >
    >
    > Each rule has
    >
    > 1. A Rule Number
    > 2. A Rule description ( Additional note to this column *may* appear in
    > subsequent lines)
    > 3. Dimension info
    > 4. Applicable devices ( may be blank or words for this column could
    > appear in subsequent lines
    > 5. Figure
    >
    >
    >
    > There are many instances where it is difficult to associate text to
    > its appropriate column.
    >
    > For example,
    >
    > ******************************************************************
    > 10.02 Enclosure of oxide isolation (L35)
    > 0.3 all devices,
    > 1, R7
    >
    > except power npn
    >
    > CEBEC
    > ******************************************************************
    >
    > is a rule where the Applicable devices column entry is 'all devices
    > except power npn CEBEC'. Since the entry is spanned over a few lines I
    > find it difficult to associate it with the appropriate column. Also ,
    > the entry for this column may be empty
    >
    >
    > Here is another example:
    >
    >
    > ******************************************************************
    >
    > 10.03 Distance to scribe line (inside DIE AREA)
    > 20.0
    > 1, R2
    >
    > Note: N+ buried layer is NOT allowed in scribe line
    > areas.
    >
    > ******************************************************************
    >
    > The Note actually belongs to the Description column.
    >
    >
    > I need to find a way in which I can attach each of the text
    > appearing in subsequent lines of a rule to its subsequent collumn.
    > PLease note that there may or may not be Notes and Applicable devices
    > column entry to each rule .
    >
    >
    > I think the code mentioned above is mostly right. I need help in
    > attching the text to its appropriate column.
    >
    > I have uploaded a copy of a sample text file here
    > http://geocities.com/knchandramohan/1920.zip
    >
    >
    > Help appreciated !
    >
    > MAny thanks
    > CM
     
    Anand, Oct 14, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. helpful sql
    Replies:
    0
    Views:
    853
    helpful sql
    May 19, 2005
  2. Stephen Noronha

    appending columns in a dataset

    Stephen Noronha, Oct 11, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    460
    Stephen Noronha
    Oct 11, 2005
  3. Replies:
    5
    Views:
    633
  4. Replies:
    4
    Views:
    964
  5. =?Utf-8?B?YmVub2l0?=

    Read CSV - string Columns - Int columns

    =?Utf-8?B?YmVub2l0?=, May 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    452
    =?Utf-8?B?YmVub2l0?=
    May 8, 2006
Loading...

Share This Page