How do u retrieve data from a text file into different
variables. i.e.
in a text file named "source" , the data is like :
india,1000,japan,200,china,50,singapore,45050
this is given in the first line of the text file.
in the second line of the text file the dta is:
sun,moon,planet,river,earth,water
if u use "readline" method by using FSO concept u can
retrieve the entire line in to a variable. but i want to
import each field (ex: "india" in one variable, "1000" in
another variable etc..). Apprecitae proper replies.
Answer Posted / rajaputra
Hi i got the solution for you.Here it is...
Just go through it, and copy and paste in QTP and run.
You will get it.
'''''''''''Importing Data From Flat File using split''''''
''Source.txt file is having following data
''Arunsingh,40000,KiranKumar,35000,Chandra,50000,Rajesh,20000
''Test Engineer,Developer,Project Leader,HR Executive
Set fso=createobject("scripting.filesystemobject")
Set z=fso.opentextfile("c:\source.txt",1)
l=1
While not z.atendofline
i=1
k=1
count=1
parname=inputbox("Enter Name of The Parameter "&l)
'''''Enter the requiered parameter names
datatable.GetSheet(1).addparameter parname,""
n=z.readline
a=split(n,",")
For j=lbound(a) to ubound(a)
If isnumeric(a(j)) Then
If count=1 Then
datatable.GetSheet(1).addparameter
"Salary",""
count=count+1
end if
datatable.SetCurrentRow(k)
m=l +1
datatable(m,1)=a(j)
k=k+1
else
datatable.SetCurrentRow(i)
datatable(l,1)=a(j)
i=i+1
end if
Next
l=m
l=l+1
Wend
If you have any doubts please contact me at
r.arunsingh@gmail.com
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
How will we compare the texts in the two word files using QTP writing the script in Descriptive Programming. Thanks
What is the difference between shared and local object repository?
How can you write the scripts that operate on different objects depending on run-time information?
i can done the project with QTP in that time i can say how many members in my team size?
Explain the concept of object repository?
In qtp, explain what is keyword driven automation framework?
If I change the property value at runtime is it effect is object repository?
Explain the features and benefits of quick test pro(qtp)?
How to save your test using quicktest professional?
write a script to verify links on any web page by using descriptive method by creating a description object (give a filter condition only link) ... need to verify expected like name by reading
wht type of User defined functions or Java Releated functions do we write in VB scripting
What processes will be required to manage updates to the web site's content, and what are the requirements for maintaining, tracking, and controlling page content, graphics, links, etc.?
What is exact meaning of Database Checkpoint in QTP 9.2 and what are the different types of the database check points?
Hello, Is there any way to send the test results in html format (or any other) by email using outlook after the test run ends? thank you in advance
how to fetch the values from grid? & qtp recogniges that grid as a webelement? what u do?