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


Please Help Members By Posting Answers For Below Questions

we add library file used in test via settings or through "ExecuteFile" command. when we implement framework do we make common library file and load the same for all the test cases execution?

1579


If an application name changes frequently i.e while recording it has the name, in this case, how do qtp handles?

582


If a button named "CLICK" is recorded in low level recording mode , what will be the values stored for "name" property of that button in object repository ?

1737


Discuss the QTP Environment?

622


Can any one tell me.......How the test engg's start testing in the compy environment.....real time tester PLSSSS help me i need in depth information regarding this...

1486






How to use reporter.report event in qtp ?

555


Explain quicktest professional testing process?

560


How is the Bitmap checkpoint different from Image checkpoint?

619


what is meant by function library?Public and private functions in function library? if private functions are applicable for only for the particular test means then y we have to add those to function library?

1373


What are parameterizing tests?

547


Explain data driven framework?

577


Explain the qtp test phases.

615


Can any one tell me how to write a script for selecting open option in File menu of A word document.here you have to add objects to OR.try like that and give me the ans.i asked this question to so many but no one knows.if any one know the answer plz let me know

1401


How to do the scripting. Is there any inbuilt functions in qtp as in qtp-s. What's the difference between them? How to handle script issues?

527


What is the basic concept of quicktest professional?

534