Forum Discussion

rmnrdi's avatar
rmnrdi
Contributor
7 years ago

Multiple DDT CSV's one test

We have an application called Job Entry. It takes some of its data from the JobEntryData.csv as shown below.

 

 

 

  var csvPath = "C:\\TestData\\JobEntryData.csv";
  Driver = DDT.CSVDriver(csvPath);
  
  ih.RunInnovationsProgram("JobEntry.exe");
  ih.LoginToInnovations("JobEntry","Ocuco","");
    
    while (!Driver.EOF())
    {
      PopulateIDPage(Driver);
      PopulateFramePage(Driver);      
      PopulateLensesPage(Driver);
      PopulateRxPage(Driver);
      PopulateExtrasPage(Driver);
      
      //Indexes to next line of data source
     Driver.Next();  
    }
      DDT.CloseDriver(Driver.Name);
}

 

 

Some of these PopulateXXXXPage() functions are straightforward, but others data will change based on a combo box. In the switch statement below, you can see the FrameSource_xxxxx changes based on a combo box value. Library, Manual, Uncut in this case.

 

 

  switch (FrameSource)
  {
    case "Library" : 
      FrameSource_Library(groupBox);
      groupBox.ckEdge2.Keys('[Enter]');
      break;  
    case "Manual" :
      FrameSource_Manual(groupBox);
      groupBox.ckEdge2.Keys('[Enter]');  
      break;
    case "Uncut" :
      FrameSource_Uncut(groupBox); 
      break;     
  }

Which executes a given function, like  the FrameSource_Library():

 

 

function FrameSource_Library(groupBox)
{
  var csvPath = "C:\\TestData\\FramesPage\\FrameSource_Library.csv";
   Driver = DDT.CSVDriver(csvPath); 
  
  var libraryTracing = Driver.Value(0);
  var type = Driver.Value(1);
  var fClass = Driver.Value(2);
  var dbl = Driver.Value(3);
  
  groupBox.cbxSource2.Keys("[Enter]");
  groupBox.ISTraceLib2.Keys(libraryTracing + "[Enter]");
  groupBox.cbxType2.Keys(type + "[Enter]");
  groupBox.cbxClass2.Keys("[Enter]");     
}

The problem I'm having is after the original pass and after the driver indexes to the next record. It uses the values from FrameSource_Library.csv and not the JobEntry.csv.

 

I'm pretty sure it has to do with the value persisting in the driver variable. 

 

Before getting into a solution, is this even a good way to do this? If not, got any suggestions?

 

I hope this is clearer than mud.

 

 

  • My best guess is this...   You have too many CSV connections open.  You need to make sure that, when you're finished iterating through a CSV result set, you use DDT.CloseDriver to close the connection. There is a limitation in the database engine for CSV connections that restricts how many connections can be open.  

     

    I see, in your code, you have the call... but it's commented out.

     

    Change that line to DDT.CloseDriver(Driver.Name) and that should work.  You need to make sure you have the same sort of call for all your DDT drivers so that you're closing the connection when it's no longer needed

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You are using the "Driver" variable in two different places... I'm assuming that's declared globally.  So, when you change the Driver to point to a different csv, that's replacing the Driver previously declared.  You should use a different variable for each driver.

    • rmnrdi's avatar
      rmnrdi
      Contributor

       

      I don't know if this is going to work anyway.

       

      For my various frame data csv's I may only have 4 rows, but in my main job entry csv I could have 50 rows.

       

      What happens when I run out of rows on one csv, but I'm still indexing through the other?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        You're not indexing through the second one anyways.... you're just grabbing the first row out of the FrameSource_Library.csv with no loop at all.  So, it really doesn't matter.  

         

        The key problem to your current code is reusing the "Driver" identifier for two different CSV files.  You should have a different identifier for each file so you can keep them distinct.