• 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. Copy a particular line of text file to a new file using...

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 144
  • Views 17147
  • 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

Copy a particular line of text file to a new file using SKILL

jarilak
jarilak over 10 years ago

Hi....

I have one text file.From that file, i need to copy some set of lines to a new file.For this copying, i need to read each & every line of the text file and compare them with some reference lines.Is there any keywords or SKILL function available in SKILL.? Can anyone help me......?

Thanks & regards 

Jarilak.r

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    jarilak said:
    Is there any keywords or SKILL function available in SKILL.?

    I have no idea what you're asking here (this part or the rest of your question). Please clarify your question, otherwise it's unlikely anyone will be able to answer it without a lucky guess as to what you're really after.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • jarilak
    jarilak over 10 years ago

    Hi...

     I am looking for little help to write a skill code for copying particular lines from a text file to a new text file. Since my original text file may contains more than 2000 lines.From that file i need  to filter some lines & copying them to new file.

    thanks & regards

    Jarilak.r

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Jarilak.r,

    That's still a pretty vague question, so here's a wild guess answer which may or may not be relevant.

    ; compile a (perl-compatible) regular expression to match lines. In
    ; this case if either of the words "wild" or "guess" appear on the input line
    pattern=pcreCompile("wild|guess")
    inp=infile("./input.txt")
    outp=outfile("./output.txt")
    when(inp && outp
      while(gets(line inp)
        when(pcreExecute(pattern line)
          fprintf(outp "%s" line)
        )
      )
      close(inp)
      close(outp)
    )

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • jarilak
    jarilak over 10 years ago
    Hi Andrew....

    This is my question.Here i have the part of text file that has more than 2000 lines.

    RULECHECK mt30m4_xx_mt30m4_un_mincoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m4_xx_mt30m4_un_maxcoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m3_xx_mt30m3_un_mincoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m3_xx_mt30m3_un_maxcoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m2_xx_mt30m2_un_mincoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m2_xx_mt30m2_un_maxcoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m1_xx_mt30m1_un_mincoverage ................... TOTAL Result Count = 0
    RULECHECK mt30m1_xx_mt30m1_un_maxcoverage ................... TOTAL Result Count = 0
    RULECHECK mt08m2_xx_mt08m2_un_mincoverage ................... TOTAL Result Count = 41
    RULECHECK mt08m2_xx_mt08m2_un_maxcoverage ................... TOTAL Result Count = 0
    RULECHECK mt08m1_xx_mt08m1_un_mincoverage ................... TOTAL Result Count = 31
    RULECHECK m1_to_m1 .......................................... TOTAL Result Count = 1
    RULECHECK m1_no ............................................. TOTAL Result Count = 0
    RULECHECK m2_to_m2........................................... TOTAL Result Count = 5
    RULECHECK m1_ma ............................................. TOTAL Result Count = 0
    RULECHECK m1inv_ma .......................................... TOTAL Result Count = 0

    From the above file, i need to filter & copy particular lines as below as.

    RULECHECK mt08m2_xx_mt08m2_un_mincoverage ................... TOTAL Result Count = 41
    RULECHECK mt08m1_xx_mt08m1_un_mincoverage ................... TOTAL Result Count = 31
    RULECHECK m1_to_m1 .......................................... TOTAL Result Count = 1
    RULECHECK m2_to_m2........................................... TOTAL Result Count = 5

    Looking for help...

    Thanks & regards
    Jarilak.r
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Couldn't you just adapt my example then? Something like:

    pattern=pcreCompile("mt08m2_xx_mt08m2_un_mincoverage|mt08m1_xx_mt08m1_un_mincoverage|m1_to_m1|m2_to_m2")

    Or you could use something like:

    listOfRules=list("mt08m2_xx_mt08m2_un_mincoverage" "mt08m1_xx_mt08m1_un_mincoverage" "m1_to_m1" "m2_to_m2")
    inp=infile("./input.txt")
    outp=outfile("./output.txt")
    when(inp && outp
      while(gets(line inp)
        when(member(cadr(parseString(line)) listOfRules)
          fprintf(outp "%s" line)
        )
      )
      close(inp)
      close(outp)
    )

    This approach would assume that the second word on each input line has whitespace either side of it (so in your example text it omits m2_to_m2 because that has a "." immediately after m2_to_m2).

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sheppy
    Sheppy over 10 years ago

    Hi Jarilak.r and Andrew,

    Jarilak, what I understood from your response to Andrew, is that you're only interested in copying lines from the DRC run results file which report errors. So rules that have a results count greater than 0. For that you just have to change the suggested code of Andrew.

    This particular part should be altered:

    listOfRules=list("TOTAL Result Count =" "TOTAL Result Count = 0")
    when(member(cadr(parseString(line)) listOfRules)
          fprintf(outp "%s" line)
        )

    The "when" should check that the first string of listOfRules list IS part of the line, and then it should make sure that the second string of listOfRules IS NOT part of that same line, thus enduring that only lines with total result count greater than 0 are copied.

    How to exactly do this, I would have to look into. It doesn't work with the "member(...)" solution, since this particular example of code works only for strings without spaces (parseString = Breaks a string into a list of substrings with break characters). You would have to use regular expression matching.

    With kind regards,

    Sjoerd

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 10 years ago

    Sjoerd, thanks for your suggestion. I'd not noticed that all the lines that Jarilak had wanted were those with a result count of other than 0. Of course, we're still guessing what Jarilak actually wants to do!

    Jarilak, this goes to show the importance of clearly stating what you want. In fact the first step of writing any program is to identify what it should do - i.e. defining the algorithm. The actual step of converting that algorithm into a specific language is secondary. If you can't state the algorithm clearly in English (or in a pseudo-langauge) first, there's little hope of implementing it in SKILL.

    If indeed you wanted all the lines with Total Result Count != 0 then I would do something like:

    pattern=pcreCompile("TOTAL Result Count =")
    inp=infile("./input.txt")
    outp=outfile("./output.txt")
    when(inp && outp
      while(gets(line inp)
        when(pcreExecute(pattern line) && atoi(car(last(parseString(line))))!=0  ; check line matches and has the last token being non-zero
          fprintf(outp "%s" line)
        )
      )
      close(inp)
      close(outp)
    )

    Please be more precise in your questions next time - whilst I understand that people are new to a programming language, that doesn't mean that it's OK to ask poorly framed questions where it requires guesswork to work out what you want. It's easier in those circumstances to just ignore the question and focus on something where a more precise question has been asked, given that we're all volunteers and have limited spare time.

    Kindest regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • jarilak
    jarilak over 10 years ago
    Hi Sjoerd & Andrew
    thanks for ur reply & am new to SKILL world.Now only, I started to learn SKILL & will come with question in precise.

    thanks & regards
    Jarilak.r
    • 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