Forum Discussion

radu's avatar
radu
Occasional Contributor
6 years ago

How to stop CSV driver to interpret/change input data

Dear all,

While I was using the CSV DDT Driver (to read some data from a csv file), I've noticed something weird: some of my data is interpreted/changed and I do not want this transformation to occur. For example:
2018-05-05 09:00:01 becomes Sat May 05 2018 09:00:01 GMT+0300 (GTB Daylight Time)
UnitsUsed [V] becomes UnitsUsed (V)

How can I configure the csv driver not to interpret the data (for any csv) and just give it to me as it is?

I've noticed that if I quote the date & time data, it is shown correctly, but I would prefer to give a setting somewhere in the code and not change all the input/output files (already created)


Unfortunately, I have no clue how to solve the second problem, i.e. the transformation of "[...]" into "(...)".


Please see the attached code, input data file, testcomplete report.

Thank you!
R

function CheckCsvDdtDriver()
{
  var path = "D:\\test4.txt";
  
  var text = aqFile.OpenTextFile(path, aqFile.faRead, aqFile.ctANSI);  
  Log.Message("The following file is read using the CSV Driver: "+path+ ". See the 'Additional Info' tab for file content", text.ReadAll());
  text.Close();
  
  var driver = DDT.CSVDriver(path);
  var lineNumber = 1;

  Log.AppendFolder("Verify the column names.");
  for (var i =0; i<driver.ColumnCount; i++)
    Log.Message("The column "+i+" is \"" +driver.ColumnName(i)+ "\".");
  Log.PopLogFolder();
  
  while (! driver.EOF())
  {
    Log.AppendFolder("Verify the row " +lineNumber+ ".");

    for (var i =0; i<driver.ColumnCount; i++)
      Log.Message("The column ["+i+"] = \"" +driver.Value(i)+ "\".");

    DDT.CurrentDriver.Next();
    lineNumber++;
    Log.PopLogFolder();
  }
  DDT.CloseDriver(DDT.CurrentDriver.Name);
  Log.Message("There are "+(lineNumber-1)+" lines (with data) within this csv file");
}

2 Replies