Following is the script to load comma separated values(CSV) from notepad into QTP datatable:
Dim fso, ts, ReadLines, Values, Rowcount
Rowcount=1 'set Rowcount variable value as 1
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1 'Set ForReading as 1
Set ts = fso.OpenTextFile("C:\testdata.txt", ForReading) 'Open the file for reading
datatable.SetCurrentRow(1)'Set cuurent row of QTP datatable as first row
Do while ts.AtEndOfStream <> True 'Looping untill the end of the file
ReadLines = ts.ReadLine() 'Read the first line in notepad
Values=Split(Readlines,",",-1,1) 'Split the line based on , (comma) delimiter
For i=0 to ubound(Values)
Datatable(Rowcount, dtlocalsheet)=Values(i) 'inserting the data in qtp local sheet
Rowcount=Rowcount+1 'shifting to next row in qtp data table
Dim fso, ts, ReadLines, Values, Rowcount
Rowcount=1 'set Rowcount variable value as 1
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1 'Set ForReading as 1
Set ts = fso.OpenTextFile("C:\testdata.txt", ForReading) 'Open the file for reading
datatable.SetCurrentRow(1)'Set cuurent row of QTP datatable as first row
Do while ts.AtEndOfStream <> True 'Looping untill the end of the file
ReadLines = ts.ReadLine() 'Read the first line in notepad
Values=Split(Readlines,",",-1,1) 'Split the line based on , (comma) delimiter
For i=0 to ubound(Values)
Datatable(Rowcount, dtlocalsheet)=Values(i) 'inserting the data in qtp local sheet
Rowcount=Rowcount+1 'shifting to next row in qtp data table
Next
Loop
No comments:
Post a Comment