Micro Focus QTP (UFT) Forums
reading data from CVS file - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: reading data from CVS file (/Thread-reading-data-from-CVS-file)



reading data from CVS file - Brian - 04-04-2008

Hi Guys,

Just wondering does anyone know how to read data in from a CVS file (comma seperated file). The file is in the format - "A","B","C", "D". I wish to read in those values as something like -
Var1 = "A"
Var2 = "B"
Var3 = "C"
Var4 = "D"

Any help on this would be great.

Cheers,
Brian


RE: reading data from CVS file - kamalteja - 04-04-2008

Hi,

You can store the value in a string i.e.,
Code:
Step 1:Set objExcel = CreateObject("Excel.Application")
Step 2:Set objWorkbook = objExcel.WorkBooks.Open("D:\TestData.xls")
Step 3:Set objDriverSheet = objWorkbook.Worksheets("Sheet1")
If Cell A1 stores the value = "A","B","C", "D"
Step 4: datataken = objDriverSheet.Cells(1, "A").value
Now  datataken will store "A","B","C", "D"
split this text with split function in vb as
Step 5: dataarray = split(datataken,",",-1)
Step 6:Var1= dataarray(0)
Step 7:Var1= dataarray(1)
Step 8:Var1= dataarray(2)
Step 9:Var1= dataarray(3)
That's it .. this code will definitely work


RE: reading data from CVS file - Brian - 04-06-2008

Thanks Kamalteja,

thats a great help, i will try that code now.