Topic
  • 5 replies
  • Latest Post - ‏2014-02-25T22:23:26Z by lokeshchaitanya
lokeshchaitanya
lokeshchaitanya
8 Posts

Pinned topic DXL script to compare 2 columns and print the report

‏2014-02-20T19:26:13Z |

Hello everyone,

 

I am new to the DXL scripting and i need one help. I am having one project module in doors and so many views in it, 

I need to have a DXL script to compare couple of columns in the Doors view i.e. i have to compare 2 attributes and generate a report.

Say in the first attribute or column in doors where ever there is a text called  "step" against a object, the corresponding second column should be with Pass/Fail. if there is nothing mentioned against the second column then the script should list down all the objects which doesnt have anything in the second column

Can some one help me out on this.

 

 

  • llandale
    llandale
    3035 Posts
    ACCEPTED ANSWER

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-20T21:43:38Z  

    How about if we just "show" the offending objects instead of "reporting" them.  If you really need a report you can "export" the filtered module.

    let me scribble, you do the debugging;

    • Module mHome = current
    • filtering off
    • Object o
    • string s1, s2
    • for o in entire mHome do
    • {  reject o      // causes it filtered out, unless we "accept" it below
    •    if (isDeleted(o)) then continue
    •    if (o is otherwise not to be considered) then continue  //Ignore Headings?  Consider only Requirements?  Objects with Links?
    •    s1 = o."NameAttr1"
    •    s2 = o."NameAttr2"
    •    if (s1 == "step"   and s2 != "Pass" and s2 != "Fail") then accept o
    • }
    • filtering on

    If the 1st attribute may "contain" the phrase "step", then you can 1st turn it ino a Regular expression, then search s1 for that.

    -Louie

  • lokeshchaitanya
    lokeshchaitanya
    8 Posts
    ACCEPTED ANSWER

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-21T21:57:56Z  
    • llandale
    • ‏2014-02-20T21:43:38Z

    How about if we just "show" the offending objects instead of "reporting" them.  If you really need a report you can "export" the filtered module.

    let me scribble, you do the debugging;

    • Module mHome = current
    • filtering off
    • Object o
    • string s1, s2
    • for o in entire mHome do
    • {  reject o      // causes it filtered out, unless we "accept" it below
    •    if (isDeleted(o)) then continue
    •    if (o is otherwise not to be considered) then continue  //Ignore Headings?  Consider only Requirements?  Objects with Links?
    •    s1 = o."NameAttr1"
    •    s2 = o."NameAttr2"
    •    if (s1 == "step"   and s2 != "Pass" and s2 != "Fail") then accept o
    • }
    • filtering on

    If the 1st attribute may "contain" the phrase "step", then you can 1st turn it ino a Regular expression, then search s1 for that.

    -Louie

    louie---Thanks for the help. based on your above post i came up with below piece of code and its working super. but at the end i want the output to be populated in a .csv or .excel file. Can you help me in updating the below code snippet to port the output result into a .csv or .xls file.

     

     

    Module m = current
     
    Object o = null
     
    string oot = ""
    int oid
    int Count = 0
     
    for o in m do {
     
    oot = o."Test Classification"
     
    if oot == "Step" then
     {
      oot = o."L3R2 Pass or Fail"
     
      if (oot == "Pass" or oot == "Fail") then 
      {
    Count ++
     
        //print  oot
                //Do nothing
      }
      else
      {
    oid = o."Absolute Number"
    print oid "\t" "Pass/Fail missing" "\n"
     
      }
       }
    }
  • GregM_dxler
    GregM_dxler
    166 Posts
    ACCEPTED ANSWER

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-24T13:49:52Z  

    louie---Thanks for the help. based on your above post i came up with below piece of code and its working super. but at the end i want the output to be populated in a .csv or .excel file. Can you help me in updating the below code snippet to port the output result into a .csv or .xls file.

     

     

    Module m = current
     
    Object o = null
     
    string oot = ""
    int oid
    int Count = 0
     
    for o in m do {
     
    oot = o."Test Classification"
     
    if oot == "Step" then
     {
      oot = o."L3R2 Pass or Fail"
     
      if (oot == "Pass" or oot == "Fail") then 
      {
    Count ++
     
        //print  oot
                //Do nothing
      }
      else
      {
    oid = o."Absolute Number"
    print oid "\t" "Pass/Fail missing" "\n"
     
      }
       }
    }

    To output something to a csv file is pretty easy.

    In the declarations at the top, declare the file by the following:

    const string sOutFileName = "c:\\temp\\MyFile.csv" //or where to put it and it's name, note the double backslashes.

    Sream out = write sOutFileName

    Then in the loop, when you want to send the data to the file you do something like,

    out << oid "," "Pass/Fail missing" "\n"

    Then at the end you close the file by

    close out

     

    Hope this helps,

    Greg

  • lokeshchaitanya
    lokeshchaitanya
    8 Posts

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-20T20:19:23Z  

    Request anyone on this forum to please help me with the script to compare the 2 different attributes and print the report.

    Thanks in advance

  • llandale
    llandale
    3035 Posts

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-20T21:43:38Z  

    How about if we just "show" the offending objects instead of "reporting" them.  If you really need a report you can "export" the filtered module.

    let me scribble, you do the debugging;

    • Module mHome = current
    • filtering off
    • Object o
    • string s1, s2
    • for o in entire mHome do
    • {  reject o      // causes it filtered out, unless we "accept" it below
    •    if (isDeleted(o)) then continue
    •    if (o is otherwise not to be considered) then continue  //Ignore Headings?  Consider only Requirements?  Objects with Links?
    •    s1 = o."NameAttr1"
    •    s2 = o."NameAttr2"
    •    if (s1 == "step"   and s2 != "Pass" and s2 != "Fail") then accept o
    • }
    • filtering on

    If the 1st attribute may "contain" the phrase "step", then you can 1st turn it ino a Regular expression, then search s1 for that.

    -Louie

  • lokeshchaitanya
    lokeshchaitanya
    8 Posts

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-21T21:57:56Z  
    • llandale
    • ‏2014-02-20T21:43:38Z

    How about if we just "show" the offending objects instead of "reporting" them.  If you really need a report you can "export" the filtered module.

    let me scribble, you do the debugging;

    • Module mHome = current
    • filtering off
    • Object o
    • string s1, s2
    • for o in entire mHome do
    • {  reject o      // causes it filtered out, unless we "accept" it below
    •    if (isDeleted(o)) then continue
    •    if (o is otherwise not to be considered) then continue  //Ignore Headings?  Consider only Requirements?  Objects with Links?
    •    s1 = o."NameAttr1"
    •    s2 = o."NameAttr2"
    •    if (s1 == "step"   and s2 != "Pass" and s2 != "Fail") then accept o
    • }
    • filtering on

    If the 1st attribute may "contain" the phrase "step", then you can 1st turn it ino a Regular expression, then search s1 for that.

    -Louie

    louie---Thanks for the help. based on your above post i came up with below piece of code and its working super. but at the end i want the output to be populated in a .csv or .excel file. Can you help me in updating the below code snippet to port the output result into a .csv or .xls file.

     

     

    Module m = current
     
    Object o = null
     
    string oot = ""
    int oid
    int Count = 0
     
    for o in m do {
     
    oot = o."Test Classification"
     
    if oot == "Step" then
     {
      oot = o."L3R2 Pass or Fail"
     
      if (oot == "Pass" or oot == "Fail") then 
      {
    Count ++
     
        //print  oot
                //Do nothing
      }
      else
      {
    oid = o."Absolute Number"
    print oid "\t" "Pass/Fail missing" "\n"
     
      }
       }
    }
  • GregM_dxler
    GregM_dxler
    166 Posts

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-24T13:49:52Z  

    louie---Thanks for the help. based on your above post i came up with below piece of code and its working super. but at the end i want the output to be populated in a .csv or .excel file. Can you help me in updating the below code snippet to port the output result into a .csv or .xls file.

     

     

    Module m = current
     
    Object o = null
     
    string oot = ""
    int oid
    int Count = 0
     
    for o in m do {
     
    oot = o."Test Classification"
     
    if oot == "Step" then
     {
      oot = o."L3R2 Pass or Fail"
     
      if (oot == "Pass" or oot == "Fail") then 
      {
    Count ++
     
        //print  oot
                //Do nothing
      }
      else
      {
    oid = o."Absolute Number"
    print oid "\t" "Pass/Fail missing" "\n"
     
      }
       }
    }

    To output something to a csv file is pretty easy.

    In the declarations at the top, declare the file by the following:

    const string sOutFileName = "c:\\temp\\MyFile.csv" //or where to put it and it's name, note the double backslashes.

    Sream out = write sOutFileName

    Then in the loop, when you want to send the data to the file you do something like,

    out << oid "," "Pass/Fail missing" "\n"

    Then at the end you close the file by

    close out

     

    Hope this helps,

    Greg

  • lokeshchaitanya
    lokeshchaitanya
    8 Posts

    Re: DXL script to compare 2 columns and print the report

    ‏2014-02-25T22:23:26Z  

    To output something to a csv file is pretty easy.

    In the declarations at the top, declare the file by the following:

    const string sOutFileName = "c:\\temp\\MyFile.csv" //or where to put it and it's name, note the double backslashes.

    Sream out = write sOutFileName

    Then in the loop, when you want to send the data to the file you do something like,

    out << oid "," "Pass/Fail missing" "\n"

    Then at the end you close the file by

    close out

     

    Hope this helps,

    Greg

    Thanks Greg. I updated as per your say and it is working now.

     

    //DXL Script to print the Pass/fail status.
     
     
    Module m = current
     
    Object o = null
     
    string oot = ""
    const string sOutFileName = "c:\\temp\\MyFile.csv" 
    Stream out = write sOutFileName
    int oid
    int Count = 0
     
    for o in m do {
     
    oot = o."Test Classification"
     
    if oot == "Step" then
     {
      oot = o."L3R2 Pass or Fail"
     
      if (oot == "Pass" or oot == "Fail") then 
      {
    Count ++
     
        //print  oot
                //Do nothing
      }
      else
      {
    oid = o."Absolute Number"
    print oid "\t" "Pass/Fail status is not updated for this object ID" "\n"
    out << oid "," "Pass/Fail missing" "\n"
     
      }
       }
     
     
     
    }

     

    In the above code snippet, can you suggest along the above status what i am printing also i need to print the Level 1 Heading along with the object ID and the statement "Pass/Fail status is not updated for this object ID"\n".

    Since i am beginner in this dxl scripting i am asking some of the silly doubts, could you pelase help me in this regard.