• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How do I parse a text file for coord pairs?

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 13790
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I parse a text file for coord pairs?

Vaughn
Vaughn over 15 years ago

I want to read a file and return a list of all the coord pairs in the file. Due to the unknown seperator between coord. I want to return any two number pairs per line.

I can use the while command to parse strings but am unable to find how to parse for numbers while reading a file.

 

  • Cancel
  • dmay
    dmay over 15 years ago

    Take a look at a post I made earlier this month:

    /forums/p/14625/24977.aspx#24977

    Assume the variable line has one line from the file. Then run the following code to store the coordinates in variable coord:
            rexCompile( "[xyXY] *[=:]")
            coord = rexReplace( line " " 0)
            rexCompile( "[(){}=,:]")
            coord = rexReplace( coord " " 0)
            rexCompile( "\\. ")
            coord = rexReplace( coord " " 0)
            coord = parseString(coord)
            ;Get only the numbers from the rest of the data
            coord=mapcar( 'aelNumber coord)
            ;Keep non-nil values
            coord=setof(x coord x)

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Vaughn
    Vaughn over 15 years ago

    Thanks Derik!!

    Can someone explain what this line is doing? 

    rexCompile( "[xyXY] *[=:]")

    Where can I find instructions or examples of what rexCompile considers regular expressions?

    Thanks 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 15 years ago

    The square brackets are used to specify a possible set of matches. This particular line finds any one of the following:

    rexCompile( "[xyXY] *[=:]")

    x=
    X =
    x:
    y:
    Y   =

    The following rexReplace will remove the X= or X: or Y= or Y: and replace it with a space. What the code is doing is trying to remove any characters that might be next to a number without a space. It is very common for x=1 to appear or y:3 to appear. The regular expression is replaced with a space so we can run the parseString in a later step.

    rexCompile( "[(){}=,:]")
    This will find and replace the equal sign, parentheses, commas, braces and colons. Again the goal is to isolate the number.

     rexCompile( "\\. ")
    The removes a period followed by a space to differentiate a float from an integer.

    Derek

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Vaughn
    Vaughn over 15 years ago

     Thanks again Derek!!

    In what manual/web page can I find instructions on regular expressions for skill?

    They are very useful.

     Vaughn

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • dmay
    dmay over 15 years ago

    In the Skill Language User Guide, look for "Pattern Matching".

     Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information