Forum Discussion

mfarshad's avatar
mfarshad
Occasional Contributor
12 years ago

Cell comaprison with CSV

Hi,

      I have Cells in my object repository. I just want to compare it with my CSV file. My Code is as follows. I can read and parse my table (cells). But the problem is with reading of csv file, storing them into a variable and then compare it with my cells. To confirm either they match or not.




sub myTest



set myPage = Aliases.browser.pagePE

set myTable = myPage.FindChild("idStr","tblTransList",20)



call ParseTable(myTable)



end sub



Sub ParseTable(ATable)



Dim i, j



Log.AppendFolder("Table")



For i = 0 To ATable.RowCount - 1



Log.AppendFolder("Row " & i)



' Goes through cells



For j = 0 To ATable.ColumnCount(i) - 1



' Obtains a cell



Set cell = ATable.Cell(i, j)



' Posts the cell's text to the log



Log.Message("Cell " & j & ": " & cell.innerText)



Next



Log.PopLogFolder()



Next



Log.PopLogFolder()



End Sub



 



Sub CSVDriver



 



' Creates a driver



DDT.CSVDriver("C:\MyFile.csv")



 



' Iterates through records



While Not DDT.CurrentDriver.EOF()



'...



DDT.CurrentDriver.Next()



WEnd



 



' Closes the driver



DDT.CloseDriver(DDT.CurrentDriver.Name)



 



End Sub



if cell.innerText = inputData.Value(cellIndex) then



Log.Message("Values matched")



else



Log.Error("Values did not match")



end if


2 Replies


  • Hi,


     


    I suggest that you save the content of your CSV file to a local variable - it should be easier to iterate through it in the same loop where you are getting the value of the cell.innerText object.