Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

Assert a Specific value in a csv file

djwhileydjwhiley Members
Hi,

I have a csv file that I can download with sahi that could look like like the following:

Date:, 01/02/2011,""
Code, Balance,""
001,1200.00,""
002,1300.00,""

How could I assert specifically the 2nd line first and second field. Then the 3rd & 4th line second field?

I have so far:

var $data = _readCSVFile("C:/tests/file.csv");
for (var $i=2; $i<$data.length-1; $i++){
var $row = $data[$i];

_assertEqual("Code", $row[0]);
_assertEqual("Balance", $row[1]);
_assertEqual("1200.00", $row[1]);
_assertEqual("1300.00", $row[1]);

}


Thanks in advance

Comments

  • maybe you could use 2D-Arrays...
    your $row[0] in _assertEqual("Code", $row[0]) can be written as $data[1][0] (which is 2. row, 1. colum )
    therefor your assert can look like this
    _assertEqual("Code", data[1][0])

    as you are checking every field by its own assert statement, the loop isn't the way to go^^
    _assertEqual("Code", data[1][0]);
    _assertEqual("Balance", data[1][1]);
    _assertEqual("1200.00",data[2][1]);
    _assertEqual("1300.00", data[2][1]);

    regards
    Wormi
  • Thanks that works.

    djwhiley
This discussion has been closed.